--- Begin Message ---
Subject: |
[PATCH] cmp: fix address spacing with -l |
Date: |
Sun, 29 Sep 2019 20:07:28 -0400 |
Looks like there's a bit of a spacing goof with 'cmp -l':
$ cat /tmp/j1
Jackdaws love my big sphinx of quartz!
$ cat /tmp/j2
jackdaws love my big sphinx of quartz.
$ ./cmp -l j1 j2
1 112 152
38 41 56
I think this fixes it.
diff --git a/src/cmp.c b/src/cmp.c
index 16e8869..3124b98 100644
--- a/src/cmp.c
+++ b/src/cmp.c
@@ -394,7 +394,7 @@ cmp (void)
if (comparison_type == type_all_diffs)
{
- off_t byte_number_max = MIN (bytes, TYPE_MAXIMUM (off_t));
+ off_t byte_number_max = bytes >= 0 ? bytes : TYPE_MAXIMUM (off_t);
for (f = 0; f < 2; f++)
if (S_ISREG (stat_buf[f].st_mode))
diff --git a/tests/cmp b/tests/cmp
index 97f2b5f..ff49388 100755
--- a/tests/cmp
+++ b/tests/cmp
@@ -218,4 +218,14 @@ case `LC_ALL=C cmp -b bad bug` in
*) echo 'expected cmp -b to report a and u'; fail=1;;
esac
+printf 'Jackdaws love my big sphinx of quartz!' > j1
+printf 'jackdaws love my big sphinx of quartz.' > j2
+cat <<'EOF' > exp2 || fail=1
+ 1 112 J 152 j
+38 41 ! 56 .
+EOF
+cmp -bl j1 j2 > out2
+test $? -eq 1 || fail=1
+compare exp2 out2 || fail=1
+
Exit $fail
Dave Odell
--- End Message ---
--- Begin Message ---
Subject: |
Re: [bug-diffutils] bug#37558: [PATCH] cmp: fix address spacing with -l |
Date: |
Tue, 1 Oct 2019 11:17:35 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 |
Thanks for the bug report, test case and fix. I installed the attached,
which fixes the bug in a different way to be portable to platforms where
off_t is narrower than intmax_t.
0001-cmp-fix-l-width-bug.patch
Description: Text Data
0002-cmp-add-test-case-for-Bug-37558.patch
Description: Text Data
--- End Message ---