\n", inf[0].name);
+ reset_last_function_match();
+ break;
+ default:
print_context_label ("***", &inf[0], file_label[0]);
print_context_label ("---", &inf[1], file_label[1]);
}
}
+void
+print_context_footer (enum context_type type)
+{
+ if (type == CONTEXT_TYPE_XML)
+ {
+ if (function_regexp.fastmap && function_tag_open)
+ fprintf(outfile, "\n");
+ fprintf(outfile, "\n");
+ function_tag_open = false;
+ }
+}
+
/* Print an edit script in context format. */
void
-print_context_script (struct change *script, bool unidiff)
+print_context_script (struct change *script, enum context_type type)
{
if (ignore_blank_lines || ignore_regexp.fastmap)
mark_ignorable (script);
]]>
': replace = ">"; break;
+ case '\'': replace = "'"; break;
+ case '\"': replace = """; break;
+ }
+ if (replace == NULL)
+ copy_function[dest++] = function[i];
+ else
+ {
+ unsigned int size = strlen(replace);
+ memcpy(©_function[dest], replace, size);
+ dest += size;
+ }
+ }
+ fwrite (copy_function, 1, dest, out);
+#undef XML_ENTITIES_EXPANSION
+#undef XML_MAX_FUNCTION_LENGTH
+}
+
/* Print a portion of an edit script in context format.
HUNK is the beginning of the portion to be printed.
The end is marked by a `link' that has been nulled out.
]]>
\n");
+
+ fprintf(out, "\n");
+ function_tag_open = true;
+ }
+
+ fprintf (out, "\n");
+
+ fprintf( out, "line0)
+ {
+ putc (initial_tab ? '\t' : ' ', out);
+ print_1_xml_line (0, &files[0].linbuf[i++]);
+ j++;
+ }
+ else
+ {
+ /* For each difference, first output the deleted part. */
+
+ k = next->deleted;
+ while (k--)
+ {
+ putc ('-', out);
+ if (initial_tab)
+ putc ('\t', out);
+ print_1_xml_line (0, &files[0].linbuf[i++]);
+ }
+
+ /* Then output the inserted part. */
+
+ k = next->inserted;
+ while (k--)
+ {
+ putc ('+', out);
+ if (initial_tab)
+ putc ('\t', out);
+ print_1_xml_line (0, &files[1].linbuf[j++]);
+ }
+
+ /* We're done with this hunk, so on to the next! */
+
+ next = next->link;
+ }
+ }
+ fprintf (out, ")]>\n");
+ fprintf (out, "\n");
+}
+
+
/* Scan a (forward-ordered) edit script for the first place that more than
2*CONTEXT unchanged lines appear, and return a pointer
to the `struct change' for the last change before those lines. */
]]>
\n", name0, name1);
+
/* If this is directory comparison, perhaps we have a file
that exists only in one of the directories.
If so, just print a message to that effect. */
]]>
\n");
/* Flush stdout so that the user sees differences immediately.
This can hurt performance, unfortunately. */
if (fflush (stdout) != 0)
]]>
buffer)
]]>
link = next;
}
}
-
+
+void
+print_1_xml_line (char const *line_flag, char const *const *line)
+{
+ /*const char* end_cdata = strstr(*line, ")]>");*/
+ char const *base = line[0], *limit = line[1]; /* Help the compiler. */
+ const unsigned int length = limit-base;
+ FILE *out = outfile; /* Help the compiler some more. */
+ char const *flag_format = 0;
+ char* copied_line;
+ char* end_cdata;
+
+ /* If -T was specified, use a Tab between the line-flag and the text.
+ Otherwise use a Space (as Unix diff does).
+ Print neither space nor tab if line-flags are empty. */
+
+ if (line_flag && *line_flag)
+ {
+ flag_format = initial_tab ? "%s\t" : "%s ";
+ fprintf (out, flag_format, line_flag);
+ }
+
+ base = copied_line = (char*)malloc(length+1);
+ limit = &copied_line[length];
+ memcpy(copied_line, line[0], length);
+ copied_line[length] = 0;
+
+ /* replace )]> by )]> because the first is not supported within the CDATA block */
+ end_cdata = strstr(copied_line, ")]>");
+ if (end_cdata != NULL)
+ end_cdata[0] = ')';
+
+ output_1_line (base, limit, flag_format, line_flag);
+
+ free(copied_line);
+
+ base = line[0];
+ limit = line[1];
+
+ if ((!line_flag || line_flag[0]) && limit[-1] != '\n')
+ fprintf (out, "\n\\ %s\n", _("No newline at end of file"));
+
+}
+
+
/* Print the text of a single line LINE,
flagging it with the characters in LINE_FLAG (which say whether
the line is inserted, deleted, changed, etc.). */
]]>