mirror of
https://https.git.savannah.gnu.org/git/diffutils.git
synced 2026-01-27 09:54:25 +00:00
cmp: fix bug in -b diagnostic
Problem reported by mancha (Bug#32249). * src/cmp.c (count_newlines): Restore old value of sentinel. * tests/cmp: Test for the bug.
This commit is contained in:
parent
612db4defa
commit
ffd63aedad
@ -639,9 +639,11 @@ count_newlines (char *buf, size_t bufsize)
|
||||
size_t count = 0;
|
||||
char *p;
|
||||
char *lim = buf + bufsize;
|
||||
char ch = *lim;
|
||||
*lim = '\n';
|
||||
for (p = buf; (p = rawmemchr (p, '\n')) != lim; p++)
|
||||
count++;
|
||||
*lim = ch;
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
10
tests/cmp
10
tests/cmp
@ -208,4 +208,14 @@ done >out1
|
||||
|
||||
compare exp1 out1 || fail=1
|
||||
|
||||
printf 'bad\n' >bad
|
||||
printf 'bug\n' >bug
|
||||
echo LC_ALL=C cmp -b bad bug
|
||||
LC_ALL=C cmp -b bad bug
|
||||
test $? -eq 1 || fail=1
|
||||
case `LC_ALL=C cmp -b bad bug` in
|
||||
'bad bug differ: byte 2, line 1 is '*' a '*' u') ;;
|
||||
*) echo 'expected cmp -b to report a and u'; fail=1;;
|
||||
esac
|
||||
|
||||
Exit $fail
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user