]> git.proxmox.com Git - libgit2.git/blobdiff - src/xdiff/xutils.c
New upstream version 1.4.3+dfsg.1
[libgit2.git] / src / xdiff / xutils.c
index 17c9ae184b6f526069290a647cae236cb69c8ba5..cfa6e2220ffd0461ce3293911c86366f6ccb1b05 100644 (file)
@@ -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;
 }