summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a0653d5)
raw | patch | inline | side by side (parent: a0653d5)
author | Brian Downing <bdowning@lavos.net> | |
Thu, 14 Aug 2008 05:36:50 +0000 (00:36 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 14 Aug 2008 06:10:23 +0000 (23:10 -0700) |
To prepare for the need to initialize and release resources for an
xdi_diff with the xdiff_outf output function, make a new function to
wrap this usage.
Old:
ecb.outf = xdiff_outf;
ecb.priv = &state;
...
xdi_diff(file_p, file_o, &xpp, &xecfg, &ecb);
New:
xdi_diff_outf(file_p, file_o, &state.xm, &xpp, &xecfg, &ecb);
Signed-off-by: Brian Downing <bdowning@lavos.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
xdi_diff with the xdiff_outf output function, make a new function to
wrap this usage.
Old:
ecb.outf = xdiff_outf;
ecb.priv = &state;
...
xdi_diff(file_p, file_o, &xpp, &xecfg, &ecb);
New:
xdi_diff_outf(file_p, file_o, &state.xm, &xpp, &xecfg, &ecb);
Signed-off-by: Brian Downing <bdowning@lavos.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-blame.c | patch | blob | history | |
combine-diff.c | patch | blob | history | |
diff.c | patch | blob | history | |
xdiff-interface.c | patch | blob | history | |
xdiff-interface.h | patch | blob | history |
diff --git a/builtin-blame.c b/builtin-blame.c
index 4ea343189fdad035318e94ce0c6c2ec16b62ba7f..8cca3b16d2ffbadb3f34c4bd80a04121f622abd3 100644 (file)
--- a/builtin-blame.c
+++ b/builtin-blame.c
xpp.flags = xdl_opts;
memset(&xecfg, 0, sizeof(xecfg));
xecfg.ctxlen = context;
- ecb.outf = xdiff_outf;
- ecb.priv = &state;
memset(&state, 0, sizeof(state));
state.xm.consume = process_u_diff;
state.ret = xmalloc(sizeof(struct patch));
state.ret->chunks = NULL;
state.ret->num = 0;
- xdi_diff(file_p, file_o, &xpp, &xecfg, &ecb);
+ xdi_diff_outf(file_p, file_o, &state.xm, &xpp, &xecfg, &ecb);
if (state.ret->num) {
struct chunk *chunk;
diff --git a/combine-diff.c b/combine-diff.c
index 9f80a1c5e3a461afd11966625589684d61187911..72dd6d22340ddd2b5f3d9c7887911a16334848bd 100644 (file)
--- a/combine-diff.c
+++ b/combine-diff.c
parent_file.size = sz;
xpp.flags = XDF_NEED_MINIMAL;
memset(&xecfg, 0, sizeof(xecfg));
- ecb.outf = xdiff_outf;
- ecb.priv = &state;
memset(&state, 0, sizeof(state));
state.xm.consume = consume_line;
state.nmask = nmask;
state.num_parent = num_parent;
state.n = n;
- xdi_diff(&parent_file, result_file, &xpp, &xecfg, &ecb);
+ xdi_diff_outf(&parent_file, result_file,
+ &state.xm, &xpp, &xecfg, &ecb);
free(parent_file.ptr);
/* Assign line numbers for this parent.
index bf5d5f15a3b54f1e1a0a2068990e899fd869d435..913a92f3e92cb489dc58c688a9e14d6a4ff9f895 100644 (file)
--- a/diff.c
+++ b/diff.c
xpp.flags = XDF_NEED_MINIMAL;
xecfg.ctxlen = diff_words->minus.alloc + diff_words->plus.alloc;
- ecb.outf = xdiff_outf;
- ecb.priv = diff_words;
diff_words->xm.consume = fn_out_diff_words_aux;
- xdi_diff(&minus, &plus, &xpp, &xecfg, &ecb);
+ xdi_diff_outf(&minus, &plus, &diff_words->xm, &xpp, &xecfg, &ecb);
free(minus.ptr);
free(plus.ptr);
xecfg.ctxlen = strtoul(diffopts + 10, NULL, 10);
else if (!prefixcmp(diffopts, "-u"))
xecfg.ctxlen = strtoul(diffopts + 2, NULL, 10);
- ecb.outf = xdiff_outf;
- ecb.priv = &ecbdata;
ecbdata.xm.consume = fn_out_consume;
if (DIFF_OPT_TST(o, COLOR_DIFF_WORDS)) {
ecbdata.diff_words =
xcalloc(1, sizeof(struct diff_words_data));
ecbdata.diff_words->file = o->file;
}
- xdi_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
+ xdi_diff_outf(&mf1, &mf2, &ecbdata.xm, &xpp, &xecfg, &ecb);
if (DIFF_OPT_TST(o, COLOR_DIFF_WORDS))
free_diff_words_data(&ecbdata);
}
memset(&xecfg, 0, sizeof(xecfg));
xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
- ecb.outf = xdiff_outf;
- ecb.priv = diffstat;
- xdi_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
+ xdi_diff_outf(&mf1, &mf2, &diffstat->xm, &xpp, &xecfg, &ecb);
}
free_and_return:
memset(&xecfg, 0, sizeof(xecfg));
xpp.flags = XDF_NEED_MINIMAL;
- ecb.outf = xdiff_outf;
- ecb.priv = &data;
- xdi_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
+ xdi_diff_outf(&mf1, &mf2, &data.xm, &xpp, &xecfg, &ecb);
if ((data.ws_rule & WS_TRAILING_SPACE) &&
data.trailing_blanks_start) {
@@ -3128,9 +3120,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
xpp.flags = XDF_NEED_MINIMAL;
xecfg.ctxlen = 3;
xecfg.flags = XDL_EMIT_FUNCNAMES;
- ecb.outf = xdiff_outf;
- ecb.priv = &data;
- xdi_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
+ xdi_diff_outf(&mf1, &mf2, &data.xm, &xpp, &xecfg, &ecb);
}
SHA1_Final(sha1, &ctx);
diff --git a/xdiff-interface.c b/xdiff-interface.c
index 61dc5c547019776b971dc89d009f628bbac134fd..828b4966a9d1e692ec7a8225406c78fca15bb5d0 100644 (file)
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
}
}
-int xdiff_outf(void *priv_, mmbuffer_t *mb, int nbuf)
+static int xdiff_outf(void *priv_, mmbuffer_t *mb, int nbuf)
{
struct xdiff_emit_state *priv = priv_;
int i;
@@ -141,6 +141,17 @@ int xdi_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t co
return xdl_diff(&a, &b, xpp, xecfg, xecb);
}
+int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,
+ struct xdiff_emit_state *state, xpparam_t const *xpp,
+ xdemitconf_t const *xecfg, xdemitcb_t *xecb)
+{
+ int ret;
+ xecb->outf = xdiff_outf;
+ xecb->priv = state;
+ ret = xdi_diff(mf1, mf2, xpp, xecfg, xecb);
+ return ret;
+}
+
int read_mmfile(mmfile_t *ptr, const char *filename)
{
struct stat st;
diff --git a/xdiff-interface.h b/xdiff-interface.h
index f7f791d96b9a34ef0f08db4b007c5309b9adc3d6..6f3b361a845f0f71ece8188e00a3cfa12138edd4 100644 (file)
--- a/xdiff-interface.h
+++ b/xdiff-interface.h
};
int xdi_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t const *xecfg, xdemitcb_t *ecb);
-int xdiff_outf(void *priv_, mmbuffer_t *mb, int nbuf);
+int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,
+ struct xdiff_emit_state *state, xpparam_t const *xpp,
+ xdemitconf_t const *xecfg, xdemitcb_t *xecb);
int parse_hunk_header(char *line, int len,
int *ob, int *on,
int *nb, int *nn);