Call the new emit_line function. Signed-off-by: Bo Yang <struggleyb.nku@xxxxxxxxx> --- diff.c | 34 +++++++++++++++++----------------- 1 files changed, 17 insertions(+), 17 deletions(-) diff --git a/diff.c b/diff.c index 2a38bef..9bd9063 100644 --- a/diff.c +++ b/diff.c @@ -194,8 +194,8 @@ struct emit_callback { sane_truncate_fn truncate; const char **label_path; struct diff_words_data *diff_words; + struct diff_options *opt; int *found_changesp; - FILE *file; struct strbuf *header; }; @@ -346,15 +346,15 @@ static void emit_add_line(const char *reset, const char *set = diff_get_color(ecbdata->color_diff, DIFF_FILE_NEW); if (!*ws) - emit_line_0(ecbdata->file, set, reset, '+', line, len); + emit_line_0(ecbdata->opt, set, reset, '+', line, len); else if (new_blank_line_at_eof(ecbdata, line, len)) /* Blank line at EOF - paint '+' as well */ - emit_line_0(ecbdata->file, ws, reset, '+', line, len); + emit_line_0(ecbdata->opt, ws, reset, '+', line, len); else { /* Emit just the prefix, then the rest. */ - emit_line_0(ecbdata->file, set, reset, '+', "", 0); + emit_line_0(ecbdata->opt, set, reset, '+', "", 0); ws_check_emit(line, len, ecbdata->ws_rule, - ecbdata->file, set, reset, ws); + ecbdata->opt->file, set, reset, ws); } } @@ -375,23 +375,23 @@ static void emit_hunk_header(struct emit_callback *ecbdata, if (len < 10 || memcmp(line, atat, 2) || !(ep = memmem(line + 2, len - 2, atat, 2))) { - emit_line(ecbdata->file, plain, reset, line, len); + emit_line(ecbdata->opt, plain, reset, line, len); return; } ep += 2; /* skip over @@ */ /* The hunk header in fraginfo color */ - emit_line(ecbdata->file, frag, reset, line, ep - line); + emit_line(ecbdata->opt, frag, reset, line, ep - line); /* blank before the func header */ for (cp = ep; ep - line < len; ep++) if (*ep != ' ' && *ep != '\t') break; if (ep != cp) - emit_line(ecbdata->file, plain, reset, cp, ep - cp); + emit_line(ecbdata->opt, plain, reset, cp, ep - cp); if (ep < line + len) - emit_line(ecbdata->file, func, reset, ep, line + len - ep); + emit_line(ecbdata->opt, func, reset, ep, line + len - ep); } static struct diff_tempfile *claim_diff_tempfile(void) { @@ -451,7 +451,7 @@ static void emit_rewrite_lines(struct emit_callback *ecb, len = endp ? (endp - data + 1) : size; if (prefix != '+') { ecb->lno_in_preimage++; - emit_line_0(ecb->file, old, reset, '-', + emit_line_0(ecb->opt, old, reset, '-', data, len); } else { ecb->lno_in_postimage++; @@ -463,7 +463,7 @@ static void emit_rewrite_lines(struct emit_callback *ecb, if (!endp) { const char *plain = diff_get_color(ecb->color_diff, DIFF_PLAIN); - emit_line_0(ecb->file, plain, reset, '\\', + emit_line_0(ecb->opt, plain, reset, '\\', nneof, strlen(nneof)); } } @@ -513,7 +513,7 @@ static void emit_rewrite_diff(const char *name_a, ecbdata.color_diff = color_diff; ecbdata.found_changesp = &o->found_changes; ecbdata.ws_rule = whitespace_rule(name_b ? name_b : name_a); - ecbdata.file = o->file; + ecbdata.opt = o; if (ecbdata.ws_rule & WS_BLANK_AT_EOF) { mmfile_t mf1, mf2; mf1.ptr = (char *)data_one; @@ -828,7 +828,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len) } if (len < 1) { - emit_line(ecbdata->file, reset, reset, line, len); + emit_line(ecbdata->opt, reset, reset, line, len); return; } @@ -845,7 +845,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len) diff_words_flush(ecbdata); line++; len--; - emit_line(ecbdata->file, plain, reset, line, len); + emit_line(ecbdata->opt, plain, reset, line, len); return; } @@ -856,7 +856,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len) ecbdata->lno_in_preimage++; if (line[0] == ' ') ecbdata->lno_in_postimage++; - emit_line(ecbdata->file, color, reset, line, len); + emit_line(ecbdata->opt, color, reset, line, len); } else { ecbdata->lno_in_postimage++; emit_add_line(reset, ecbdata, line + 1, len - 1); @@ -1421,7 +1421,7 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len) fprintf(data->o->file, "%s:%d: %s.\n", data->filename, data->lineno, err); free(err); - emit_line(data->o->file, set, reset, line, 1); + emit_line(data->o, set, reset, line, 1); ws_check_emit(line + 1, len - 1, data->ws_rule, data->o->file, set, reset, ws); } else if (line[0] == ' ') { @@ -1731,7 +1731,7 @@ static void builtin_diff(const char *name_a, ecbdata.ws_rule = whitespace_rule(name_b ? name_b : name_a); if (ecbdata.ws_rule & WS_BLANK_AT_EOF) check_blank_at_eof(&mf1, &mf2, &ecbdata); - ecbdata.file = o->file; + ecbdata.opt = o; ecbdata.header = header.len ? &header : NULL; xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts; xecfg.ctxlen = o->context; -- 1.7.1.94.gc3269 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html