Optionally emit function names in the hunk headers.
PATCH 1/3 Optionally emit function names in the hunk headers.
From: Mark Wooding <[email protected]>
This is a patch on top of libxdiff 0.21 we use in the git project.
--- xdiff.h | 5 ++++- xemit.c | 41 ++++++++++++++++++++++++++++++++++++++++- xpatchi.c | 2 +- xutils.c | 31 ++++++++++++++++++++++--------- xutils.h | 3 ++- 5 files changed, 69 insertions(+), 13 deletions(-)
xdiff.h +4 -1
@@ -34,7 +34,9 @@ #define XDL_PATCH_NORMAL '-'#define XDL_PATCH_REVERSE '+'#define XDL_PATCH_MODEMASK ((1 << 8) - 1)#define XDL_PATCH_IGNOREBSPACE (1 << 8) - + +#define XDL_EMIT_FUNCNAMES (1 << 0) +#define XDL_MMB_READONLY (1 << 0)#define XDL_MMF_ATOMIC (1 << 0)
@@ -82,6 +84,7 @@ typedef struct s_xdemitcb {typedef struct s_xdemitconf {long ctxlen; +unsigned long flags; }xdemitconf_t ; typedef struct s_bdiffparam {
xemit.c +40 -1
57 lines not on this page · raw message
xpatchi.c +1 -1
@@ -530,7 +530,7 @@ static int xdl_reject_hunk(recfile_t *rf c2 = pch->hi.c1; } s1 += pch->ps.adds - pch->ps.dels; -if (xdl_emit_hunk_hdr (s1 +1 , c1, s2 +1 , c2, rjecb) <0 ) { +if (xdl_emit_hunk_hdr (s1 +1 , c1, s2 +1 , c2,NULL ,0 , rjecb) <0 ) {return -1 ; }
xutils.c +22 -9
@@ -542,7 +542,8 @@ long xdl_atol(char const *str, char cons } -int xdl_emit_hunk_hdr (long s1,long c1,long s2,long c2,xdemitcb_t *ecb) { +int xdl_emit_hunk_hdr (long s1,long c1,long s2,long c2, +const char *func,long funclen,xdemitcb_t *ecb) {int nb =0 ;mmbuffer_t mb;char buf[128 ];
@@ -552,23 +553,35 @@ int xdl_emit_hunk_hdr(long s1, long c1, nb +=xdl_num_out (buf + nb, c1 ? s1: s1 -1 ); -memcpy (buf + nb,"," ,1 ); - nb +=1 ; +if (c1 !=1 ) { +memcpy (buf + nb,"," ,1 ); + nb +=1 ; - nb +=xdl_num_out (buf + nb, c1); + nb +=xdl_num_out (buf + nb, c1); + }memcpy (buf + nb," +" ,2 ); nb +=2 ; nb +=xdl_num_out (buf + nb, c2 ? s2: s2 -1 ); -memcpy (buf + nb,"," ,1 ); - nb +=1 ; +if (c2 !=1 ) { +memcpy (buf + nb,"," ,1 ); + nb +=1 ; - nb +=xdl_num_out (buf + nb, c2); + nb +=xdl_num_out (buf + nb, c2); + } -memcpy (buf + nb," @@\n" ,4 ); - nb +=4 ; +memcpy (buf + nb," @@" ,3 ); + nb +=3 ; +if (func && funclen) { + buf[nb++] =' ' ; +if (funclen >sizeof (buf) - nb -1 ) + funclen =sizeof (buf) - nb -1 ; +memcpy (buf + nb, func, funclen); + nb += funclen; + } + buf[nb++] ='\n' ; mb.ptr = buf; mb.size = nb;
xutils.h +2 -1
@@ -39,7 +39,8 @@ unsigned long xdl_hash_record(char constunsigned int xdl_hashbits (unsigned int size);int xdl_num_out (char *out,long val);long xdl_atol (char const *str,char const **next); -int xdl_emit_hunk_hdr (long s1,long c1,long s2,long c2,xdemitcb_t *ecb); +int xdl_emit_hunk_hdr (long s1,long c1,long s2,long c2, +const char *func,long funclen,xdemitcb_t *ecb);
Signature · 1 line
1.4.0.gbf9e