emit_line_0(o, set, reset, line[0], line+1, len-1);
}
+enum diff_symbol {
+ DIFF_SYMBOL_CONTEXT_MARKER,
+ DIFF_SYMBOL_SEPARATOR
+};
+
+static void emit_diff_symbol(struct diff_options *o, enum diff_symbol s,
+ const char *line, int len)
+{
+ const char *context, *reset;
+ switch (s) {
+ case DIFF_SYMBOL_CONTEXT_MARKER:
+ context = diff_get_color_opt(o, DIFF_CONTEXT);
+ reset = diff_get_color_opt(o, DIFF_RESET);
+ emit_line(o, context, reset, line, len);
+ break;
+ case DIFF_SYMBOL_SEPARATOR:
+ fprintf(o->file, "%s%c",
+ diff_line_prefix(o),
+ o->line_termination);
+ break;
+ default:
+ die("BUG: unknown diff symbol");
+ }
+}
+
static int new_blank_line_at_eof(struct emit_callback *ecbdata, const char *line, int len)
{
if (!((ecbdata->ws_rule & WS_BLANK_AT_EOF) &&
if (len < 10 ||
memcmp(line, atat, 2) ||
!(ep = memmem(line + 2, len - 2, atat, 2))) {
- emit_line(ecbdata->opt, context, reset, line, len);
+ emit_diff_symbol(ecbdata->opt,
+ DIFF_SYMBOL_CONTEXT_MARKER, line, len);
return;
}
ep += 2; /* skip over @@ */
if (output_format & DIFF_FORMAT_PATCH) {
if (separator) {
- fprintf(options->file, "%s%c",
- diff_line_prefix(options),
- options->line_termination);
+ emit_diff_symbol(options, DIFF_SYMBOL_SEPARATOR, NULL, 0);
if (options->stat_sep) {
/* attach patch instead of inline */
fputs(options->stat_sep, options->file);