mirror of
https://https.git.savannah.gnu.org/git/diffutils.git
synced 2026-01-27 01:44:20 +00:00
diff: fix bug with diff -B and incomplete lines
Reported by Navin Kabra via Eric Blake in: http://bugs.gnu.org/18402 * src/util.c (analyze_hunk): Don't mishandle incomplete lines at end of file. * tests/no-newline-at-eof: Test for the bug.
This commit is contained in:
parent
7bdd6479ce
commit
d2fd9d4683
@ -817,7 +817,8 @@ analyze_hunk (struct change *hunk,
|
||||
for (i = next->line0; i <= l0 && trivial; i++)
|
||||
{
|
||||
char const *line = linbuf0[i];
|
||||
char const *newline = linbuf0[i + 1] - 1;
|
||||
char const *lastbyte = linbuf0[i + 1] - 1;
|
||||
char const *newline = lastbyte + (*lastbyte != '\n');
|
||||
size_t len = newline - line;
|
||||
char const *p = line;
|
||||
if (skip_white_space)
|
||||
@ -837,7 +838,8 @@ analyze_hunk (struct change *hunk,
|
||||
for (i = next->line1; i <= l1 && trivial; i++)
|
||||
{
|
||||
char const *line = linbuf1[i];
|
||||
char const *newline = linbuf1[i + 1] - 1;
|
||||
char const *lastbyte = linbuf1[i + 1] - 1;
|
||||
char const *newline = lastbyte + (*lastbyte != '\n');
|
||||
size_t len = newline - line;
|
||||
char const *p = line;
|
||||
if (skip_white_space)
|
||||
|
||||
@ -50,4 +50,10 @@ compare exp2 out || fail=1
|
||||
# expect empty stderr
|
||||
compare /dev/null err || fail=1
|
||||
|
||||
# Test for Bug#18402.
|
||||
printf a > a
|
||||
printf b > b
|
||||
diff -B a b > out 2>err
|
||||
test $? = 1 || fail=1
|
||||
|
||||
Exit $fail
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user