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.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: "dmo2118 <at> gmail.com" <dmo2118 <at> gmail.com>
Subject: bug#37558: closed (Re: [bug-diffutils] bug#37558: [PATCH] cmp:
 fix address spacing with -l)
Date: Tue, 01 Oct 2019 18:18:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#37558: [PATCH] cmp: fix address spacing with -l

which was filed against the diffutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 37558 <at> debbugs.gnu.org.

-- 
37558: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=37558
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
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 3 (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)]
[Message part 6 (message/rfc822, inline)]
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



This bug report was last modified 5 years and 291 days ago.

Previous Next


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