Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
xdiff: factor out is_func_rec()
author
René Scharfe
<l.s.r@web.de>
Sat, 18 Nov 2017 18:04:40 +0000
(19:04 +0100)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 21 Nov 2017 00:36:06 +0000
(09:36 +0900)
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>
xdiff/xemit.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
eced93b
)
diff --git
a/xdiff/xemit.c
b/xdiff/xemit.c
index 6881445e4afc3482ba008ebbdab81b51167863fc..c2d5bd004c72fc5361ea72884fb455be2281e260 100644
(file)
--- 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);
}
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];
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) {
/* Appended chunk? */
if (i1 >= xe->xdf1.nrec) {
- char dummy[1];
long i2 = xch->i2;
/*
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) {
* 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++;
}
goto post_context_calculation;
i2++;
}