GNU bug report logs - #37558
[PATCH] cmp: fix address spacing with -l

Previous Next

Package: diffutils;

Reported by: "dmo2118 <at> gmail.com" <dmo2118 <at> gmail.com>

Date: Mon, 30 Sep 2019 00:33:02 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 37558 in the body.
You can then email your comments to 37558 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-diffutils <at> gnu.org:
bug#37558; Package diffutils. (Mon, 30 Sep 2019 00:33:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "dmo2118 <at> gmail.com" <dmo2118 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-diffutils <at> gnu.org. (Mon, 30 Sep 2019 00:33:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "dmo2118 <at> gmail.com" <dmo2118 <at> gmail.com>
To: bug-diffutils <at> gnu.org
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




Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Tue, 01 Oct 2019 18:18:02 GMT) Full text and rfc822 format available.

Notification sent to "dmo2118 <at> gmail.com" <dmo2118 <at> gmail.com>:
bug acknowledged by developer. (Tue, 01 Oct 2019 18:18:02 GMT) Full text and rfc822 format available.

Message #10 received at 37558-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: "dmo2118 <at> gmail.com" <dmo2118 <at> gmail.com>, 37558-done <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#37558: [PATCH] cmp: fix address spacing with
 -l
Date: Tue, 1 Oct 2019 11:17:35 -0700
[Message part 1 (text/plain, inline)]
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 (text/x-patch, attachment)]
[0002-cmp-add-test-case-for-Bug-37558.patch (text/x-patch, attachment)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 30 Oct 2019 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 173 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.