diff options
Diffstat (limited to 'xdiff')
-rw-r--r-- | xdiff/xdiff.h | 5 | ||||
-rw-r--r-- | xdiff/xdiffi.c | 1 | ||||
-rw-r--r-- | xdiff/xdiffi.h | 1 | ||||
-rw-r--r-- | xdiff/xemit.c | 42 | ||||
-rw-r--r-- | xdiff/xemit.h | 1 | ||||
-rw-r--r-- | xdiff/xinclude.h | 1 | ||||
-rw-r--r-- | xdiff/xmacros.h | 1 | ||||
-rw-r--r-- | xdiff/xprepare.c | 1 | ||||
-rw-r--r-- | xdiff/xprepare.h | 1 | ||||
-rw-r--r-- | xdiff/xtypes.h | 1 | ||||
-rw-r--r-- | xdiff/xutils.c | 1 | ||||
-rw-r--r-- | xdiff/xutils.h | 1 |
12 files changed, 29 insertions, 28 deletions
diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h index e874a7c46a..c00ddaa6e9 100644 --- a/xdiff/xdiff.h +++ b/xdiff/xdiff.h @@ -73,9 +73,13 @@ typedef struct s_xdemitcb { int (*outf)(void *, mmbuffer_t *, int); } xdemitcb_t; +typedef long (*find_func_t)(const char *line, long line_len, char *buffer, long buffer_size, void *priv); + typedef struct s_xdemitconf { long ctxlen; unsigned long flags; + find_func_t find_func; + void *find_func_priv; } xdemitconf_t; typedef struct s_bdiffparam { @@ -103,4 +107,3 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1, #endif /* #ifdef __cplusplus */ #endif /* #if !defined(XDIFF_H) */ - diff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c index 9aeebc473b..5cb7171a8f 100644 --- a/xdiff/xdiffi.c +++ b/xdiff/xdiffi.c @@ -565,4 +565,3 @@ int xdl_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, return 0; } - diff --git a/xdiff/xdiffi.h b/xdiff/xdiffi.h index 472aeaecfa..3e099dc445 100644 --- a/xdiff/xdiffi.h +++ b/xdiff/xdiffi.h @@ -57,4 +57,3 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, xdemitconf_t const *xecfg); #endif /* #if !defined(XDIFFI_H) */ - diff --git a/xdiff/xemit.c b/xdiff/xemit.c index e291dc7608..d3d9c845c6 100644 --- a/xdiff/xemit.c +++ b/xdiff/xemit.c @@ -69,7 +69,24 @@ static xdchange_t *xdl_get_hunk(xdchange_t *xscr, xdemitconf_t const *xecfg) { } -static void xdl_find_func(xdfile_t *xf, long i, char *buf, long sz, long *ll) { +static long def_ff(const char *rec, long len, char *buf, long sz, void *priv) +{ + if (len > 0 && + (isalpha((unsigned char)*rec) || /* identifier? */ + *rec == '_' || /* also identifier? */ + *rec == '$')) { /* identifiers from VMS and other esoterico */ + if (len > sz) + len = sz; + while (0 < len && isspace((unsigned char)rec[len - 1])) + len--; + memcpy(buf, rec, len); + return len; + } + return -1; +} + +static void xdl_find_func(xdfile_t *xf, long i, char *buf, long sz, long *ll, + find_func_t ff, void *ff_priv) { /* * Be quite stupid about this for now. Find a line in the old file @@ -80,27 +97,17 @@ static void xdl_find_func(xdfile_t *xf, long i, char *buf, long sz, long *ll) { const char *rec; long len; - *ll = 0; while (i-- > 0) { len = xdl_get_rec(xf, i, &rec); - if (len > 0 && - (isalpha((unsigned char)*rec) || /* identifier? */ - *rec == '_' || /* also identifier? */ - *rec == '$')) { /* mysterious GNU diff's invention */ - if (len > sz) - len = sz; - while (0 < len && isspace((unsigned char)rec[len - 1])) - len--; - memcpy(buf, rec, len); - *ll = len; + if ((*ll = ff(rec, len, buf, sz, ff_priv)) >= 0) return; - } } + *ll = 0; } -int xdl_emit_common(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, - xdemitconf_t const *xecfg) { +static int xdl_emit_common(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, + xdemitconf_t const *xecfg) { xdfile_t *xdf = &xe->xdf1; const char *rchg = xdf->rchg; long ix; @@ -120,6 +127,7 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, xdchange_t *xch, *xche; char funcbuf[80]; long funclen = 0; + find_func_t ff = xecfg->find_func ? xecfg->find_func : def_ff; if (xecfg->flags & XDL_EMIT_COMMON) return xdl_emit_common(xe, xscr, ecb, xecfg); @@ -143,7 +151,8 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, if (xecfg->flags & XDL_EMIT_FUNCNAMES) { xdl_find_func(&xe->xdf1, s1, funcbuf, - sizeof(funcbuf), &funclen); + sizeof(funcbuf), &funclen, + ff, xecfg->find_func_priv); } if (xdl_emit_hunk_hdr(s1 + 1, e1 - s1, s2 + 1, e2 - s2, funcbuf, funclen, ecb) < 0) @@ -194,4 +203,3 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, return 0; } - diff --git a/xdiff/xemit.h b/xdiff/xemit.h index e629417dd2..440a7390fa 100644 --- a/xdiff/xemit.h +++ b/xdiff/xemit.h @@ -31,4 +31,3 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, #endif /* #if !defined(XEMIT_H) */ - diff --git a/xdiff/xinclude.h b/xdiff/xinclude.h index 04a9da82c9..526ccb344d 100644 --- a/xdiff/xinclude.h +++ b/xdiff/xinclude.h @@ -40,4 +40,3 @@ #endif /* #if !defined(XINCLUDE_H) */ - diff --git a/xdiff/xmacros.h b/xdiff/xmacros.h index e2cd2023b3..8ef232cfad 100644 --- a/xdiff/xmacros.h +++ b/xdiff/xmacros.h @@ -51,4 +51,3 @@ do { \ #endif /* #if !defined(XMACROS_H) */ - diff --git a/xdiff/xprepare.c b/xdiff/xprepare.c index 1be7b31950..e87ab57c65 100644 --- a/xdiff/xprepare.c +++ b/xdiff/xprepare.c @@ -466,4 +466,3 @@ static int xdl_optimize_ctxs(xdfile_t *xdf1, xdfile_t *xdf2) { return 0; } - diff --git a/xdiff/xprepare.h b/xdiff/xprepare.h index 344c569e8b..8fb06a5374 100644 --- a/xdiff/xprepare.h +++ b/xdiff/xprepare.h @@ -32,4 +32,3 @@ void xdl_free_env(xdfenv_t *xe); #endif /* #if !defined(XPREPARE_H) */ - diff --git a/xdiff/xtypes.h b/xdiff/xtypes.h index 3593a664fc..2511aef8d8 100644 --- a/xdiff/xtypes.h +++ b/xdiff/xtypes.h @@ -65,4 +65,3 @@ typedef struct s_xdfenv { #endif /* #if !defined(XTYPES_H) */ - diff --git a/xdiff/xutils.c b/xdiff/xutils.c index bf91c0f73c..2ade97b257 100644 --- a/xdiff/xutils.c +++ b/xdiff/xutils.c @@ -380,4 +380,3 @@ int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, return 0; } - diff --git a/xdiff/xutils.h b/xdiff/xutils.h index 70d8b9838a..d5de8292e0 100644 --- a/xdiff/xutils.h +++ b/xdiff/xutils.h @@ -45,4 +45,3 @@ int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, #endif /* #if !defined(XUTILS_H) */ - |