summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7680087)
raw | patch | inline | side by side (parent: 7680087)
author | Jeff King <peff@peff.net> | |
Sun, 16 Dec 2007 07:06:14 +0000 (02:06 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 16 Dec 2007 19:53:03 +0000 (11:53 -0800) |
The recovered context lines were not LF terminated due to off-by-one
error, which also caused the outer loop to count the number of recovered
lines to terminate after running only once.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
error, which also caused the outer loop to count the number of recovered
lines to terminate after running only once.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
xdiff-interface.c | patch | blob | history |
diff --git a/xdiff-interface.c b/xdiff-interface.c
index 700def211e25a61591d4609ef19d64d91319f33e..98b02eda3576505e621099c75abdf75f4a403f27 100644 (file)
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
static void trim_common_tail(mmfile_t *a, mmfile_t *b, long ctx)
{
const int blk = 1024;
- long trimmed = 0, recovered = 0, i;
+ long trimmed = 0, recovered = 0;
char *ap = a->ptr + a->size;
char *bp = b->ptr + b->size;
long smaller = (a->size < b->size) ? a->size : b->size;
bp -= blk;
}
- for (i = 0, recovered = 0; recovered < trimmed && i <= ctx; i++) {
- while (recovered < trimmed && ap[recovered] != '\n')
- recovered++;
- }
+ while (recovered < trimmed && ctx)
+ if (ap[recovered++] == '\n')
+ ctx--;
a->size -= (trimmed - recovered);
b->size -= (trimmed - recovered);
}