X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=src%2Fxdiff%2Fxutils.c;h=cfa6e2220ffd0461ce3293911c86366f6ccb1b05;hb=e579e0f70726f20d8b946b256f6cf90efdbf7d9a;hp=17c9ae184b6f526069290a647cae236cb69c8ba5;hpb=c25aa7cd825ba972c2a1a902c73ce3a8c8a59ec3;p=libgit2.git diff --git a/src/xdiff/xutils.c b/src/xdiff/xutils.c index 17c9ae184..cfa6e2220 100644 --- a/src/xdiff/xutils.c +++ b/src/xdiff/xutils.c @@ -23,8 +23,6 @@ #include "xinclude.h" - - long xdl_bogosqrt(long n) { long i; @@ -52,7 +50,7 @@ int xdl_emit_diffrec(char const *rec, long size, char const *pre, long psize, mb[2].size = strlen(mb[2].ptr); i++; } - if (ecb->outf(ecb->priv, mb, i) < 0) { + if (ecb->out_line(ecb->priv, mb, i) < 0) { return -1; } @@ -342,8 +340,9 @@ int xdl_num_out(char *out, long val) { return str - out; } -int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, - const char *func, long funclen, xdemitcb_t *ecb) { +static int xdl_format_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]; @@ -376,7 +375,7 @@ int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, nb += 3; if (func && funclen) { buf[nb++] = ' '; - if (funclen > (long)(sizeof(buf) - nb - 1)) + if (funclen > sizeof(buf) - nb - 1) funclen = sizeof(buf) - nb - 1; memcpy(buf + nb, func, funclen); nb += funclen; @@ -385,9 +384,21 @@ int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, mb.ptr = buf; mb.size = nb; - if (ecb->outf(ecb->priv, &mb, 1) < 0) + if (ecb->out_line(ecb->priv, &mb, 1) < 0) return -1; + return 0; +} +int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, + const char *func, long funclen, + xdemitcb_t *ecb) { + if (!ecb->out_hunk) + return xdl_format_hunk_hdr(s1, c1, s2, c2, func, funclen, ecb); + if (ecb->out_hunk(ecb->priv, + c1 ? s1 : s1 - 1, c1, + c2 ? s2 : s2 - 1, c2, + func, funclen) < 0) + return -1; return 0; }