summaryrefslogtreecommitdiffstats
path: root/xdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-11-18 19:04:40 +0100
committerJunio C Hamano <gitster@pobox.com>2017-11-21 09:36:06 +0900
commitcde32bf62f74758d3bad685f9fef6aea4e10d106 (patch)
treea005535d9a082bfd89476370ef4e36959fb62093 /xdiff
parenteced93bcb8647ad7dad6511e0d58a4dad470f473 (diff)
downloadgit-cde32bf62f74758d3bad685f9fef6aea4e10d106.tar.gz
git-cde32bf62f74758d3bad685f9fef6aea4e10d106.tar.xz
xdiff: factor out is_func_rec()
Add a helper for checking if a given record is a function line. It frees callers from having to deal with the buffer arguments of match_func_rec(). Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'xdiff')
-rw-r--r--xdiff/xemit.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/xdiff/xemit.c b/xdiff/xemit.c
index 6881445e4..c2d5bd004 100644
--- a/xdiff/xemit.c
+++ b/xdiff/xemit.c
@@ -121,6 +121,12 @@ static long match_func_rec(xdfile_t *xdf, xdemitconf_t const *xecfg, long ri,
return xecfg->find_func(rec, len, buf, sz, xecfg->find_func_priv);
}
+static int is_func_rec(xdfile_t *xdf, xdemitconf_t const *xecfg, long ri)
+{
+ char dummy[1];
+ return match_func_rec(xdf, xecfg, ri, dummy, sizeof(dummy)) >= 0;
+}
+
struct func_line {
long len;
char buf[80];
@@ -178,7 +184,6 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
/* Appended chunk? */
if (i1 >= xe->xdf1.nrec) {
- char dummy[1];
long i2 = xch->i2;
/*
@@ -186,8 +191,7 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
* a whole function was added.
*/
while (i2 < xe->xdf2.nrec) {
- if (match_func_rec(&xe->xdf2, xecfg, i2,
- dummy, sizeof(dummy)) >= 0)
+ if (is_func_rec(&xe->xdf2, xecfg, i2))
goto post_context_calculation;
i2++;
}