Blame SOURCES/diffutils-cmp-sentinel.patch
|
Pablo Greco |
4e425e |
From ffd63aedad3c0eb08ebb27103e5f242f8732dc0c Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
4e425e |
From: Paul Eggert <eggert@cs.ucla.edu>
|
|
Pablo Greco |
4e425e |
Date: Tue, 24 Jul 2018 10:18:28 -0700
|
|
Pablo Greco |
4e425e |
Subject: cmp: fix bug in -b diagnostic
|
|
Pablo Greco |
4e425e |
|
|
Pablo Greco |
4e425e |
Problem reported by mancha (Bug#32249).
|
|
Pablo Greco |
4e425e |
* src/cmp.c (count_newlines): Restore old value of sentinel.
|
|
Pablo Greco |
4e425e |
* tests/cmp: Test for the bug.
|
|
Pablo Greco |
4e425e |
---
|
|
Pablo Greco |
4e425e |
src/cmp.c | 2 ++
|
|
Pablo Greco |
4e425e |
tests/cmp | 10 ++++++++++
|
|
Pablo Greco |
4e425e |
2 files changed, 12 insertions(+)
|
|
Pablo Greco |
4e425e |
|
|
Pablo Greco |
4e425e |
diff --git a/src/cmp.c b/src/cmp.c
|
|
Pablo Greco |
4e425e |
index 04638e3..2811392 100644
|
|
Pablo Greco |
4e425e |
--- a/src/cmp.c
|
|
Pablo Greco |
4e425e |
+++ b/src/cmp.c
|
|
Pablo Greco |
4e425e |
@@ -639,9 +639,11 @@ count_newlines (char *buf, size_t bufsize)
|
|
Pablo Greco |
4e425e |
size_t count = 0;
|
|
Pablo Greco |
4e425e |
char *p;
|
|
Pablo Greco |
4e425e |
char *lim = buf + bufsize;
|
|
Pablo Greco |
4e425e |
+ char ch = *lim;
|
|
Pablo Greco |
4e425e |
*lim = '\n';
|
|
Pablo Greco |
4e425e |
for (p = buf; (p = rawmemchr (p, '\n')) != lim; p++)
|
|
Pablo Greco |
4e425e |
count++;
|
|
Pablo Greco |
4e425e |
+ *lim = ch;
|
|
Pablo Greco |
4e425e |
return count;
|
|
Pablo Greco |
4e425e |
}
|
|
Pablo Greco |
4e425e |
|
|
Pablo Greco |
4e425e |
diff --git a/tests/cmp b/tests/cmp
|
|
Pablo Greco |
4e425e |
index 160c1ea..ca0fe5e 100755
|
|
Pablo Greco |
4e425e |
--- a/tests/cmp
|
|
Pablo Greco |
4e425e |
+++ b/tests/cmp
|
|
Pablo Greco |
4e425e |
@@ -208,4 +208,14 @@ done >out1
|
|
Pablo Greco |
4e425e |
|
|
Pablo Greco |
4e425e |
compare exp1 out1 || fail=1
|
|
Pablo Greco |
4e425e |
|
|
Pablo Greco |
4e425e |
+printf 'bad\n' >bad
|
|
Pablo Greco |
4e425e |
+printf 'bug\n' >bug
|
|
Pablo Greco |
4e425e |
+echo LC_ALL=C cmp -b bad bug
|
|
Pablo Greco |
4e425e |
+LC_ALL=C cmp -b bad bug
|
|
Pablo Greco |
4e425e |
+test $? -eq 1 || fail=1
|
|
Pablo Greco |
4e425e |
+case `LC_ALL=C cmp -b bad bug` in
|
|
Pablo Greco |
4e425e |
+ 'bad bug differ: byte 2, line 1 is '*' a '*' u') ;;
|
|
Pablo Greco |
4e425e |
+ *) echo 'expected cmp -b to report a and u'; fail=1;;
|
|
Pablo Greco |
4e425e |
+esac
|
|
Pablo Greco |
4e425e |
+
|
|
Pablo Greco |
4e425e |
Exit $fail
|
|
Pablo Greco |
4e425e |
--
|
|
Pablo Greco |
4e425e |
cgit v1.0-41-gc330
|
|
Pablo Greco |
4e425e |
|