GNU bug report logs - #24154
bug in 'diff -B'

Previous Next

Package: diffutils;

Reported by: "Zieg, Mark (KSC-ESC-624)[VENCORE-ESC]" <mark.zieg <at> nasa.gov>

Date: Thu, 4 Aug 2016 22:23:02 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

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: "Zieg, Mark (KSC-ESC-624)[VENCORE-ESC]" <mark.zieg <at> nasa.gov>
Subject: bug#24154: closed (Re: [bug-diffutils] bug#24154: bug in 'diff -B')
Date: Thu, 04 Aug 2016 23:32:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#24154: bug in 'diff -B'

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 24154 <at> debbugs.gnu.org.

-- 
24154: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=24154
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Jim Meyering <jim <at> meyering.net>
To: "Zieg, Mark (KSC-ESC-624)[VENCORE-ESC]" <mark.zieg <at> nasa.gov>
Cc: 24154-done <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#24154: bug in 'diff -B'
Date: Thu, 4 Aug 2016 16:30:43 -0700
On Thu, Aug 4, 2016 at 2:43 PM, Zieg, Mark (KSC-ESC-624)[VENCORE-ESC]
<mark.zieg <at> nasa.gov> wrote:
> When diffing an empty file against a one-byte file using -B (--ignore-blank-lines), diff incorrectly reports that the files are identical, even though they aren't even the same size.  The problem does not occur with files of 2 bytes or longer.  I tested this with diffutils 2.8, 3.2 and 3.3.
...
> # HERE IS THE PROBLEM: diff -B does NOT work as expected
> deedwl262 [~/work/test] mzieg 09:18 PM $ diff -B foo bar

Thank you for the report. I confirm it was a problem with diffutils-3.3:

$ /usr/bin/diff --version|head -1
diff (GNU diffutils) 3.3
$ printf 1 > 1; : > 0; /usr/bin/diff -B 0 1
$ printf 1 > 1; : > 0; /usr/bin/diff -B 1 0
$

It was fixed with this commit, which will be part of the imminent
diffutils-3.4 release:

commit d2fd9d4683ef60c259a3b426f71cef1b89ff383d
Author: Paul Eggert <eggert <at> cs.ucla.edu>
Date:   Wed Sep 3 15:58:03 2014 -0700

    diff: fix bug with diff -B and incomplete lines

    Reported by Navin Kabra via Eric Blake in:
    http://bugs.gnu.org/18402
    * src/util.c (analyze_hunk): Don't mishandle incomplete
    lines at end of file.
    * tests/no-newline-at-eof: Test for the bug.

So I've marked this auto-created "issue" as resolved.

[Message part 3 (message/rfc822, inline)]
From: "Zieg, Mark (KSC-ESC-624)[VENCORE-ESC]" <mark.zieg <at> nasa.gov>
To: "bug-diffutils <at> gnu.org" <bug-diffutils <at> gnu.org>
Subject: bug in 'diff -B'
Date: Thu, 4 Aug 2016 21:43:45 +0000
Hello,

When diffing an empty file against a one-byte file using -B (--ignore-blank-lines), diff incorrectly reports that the files are identical, even though they aren't even the same size.  The problem does not occur with files of 2 bytes or longer.  I tested this with diffutils 2.8, 3.2 and 3.3.

How to reproduce:

# create a one-byte file "foo"
deedwl262 [~/work/test] mzieg 09:17 PM $ echo -n x > foo

# create a zero-byte file "bar"
deedwl262 [~/work/test] mzieg 09:17 PM $ echo -n > bar

# confirm file sizes
deedwl262 [~/work/test] mzieg 09:18 PM $ ls -la
-rw-rw-r-- 1 mzieg unixusers 0 Aug  4 21:18 bar
-rw-rw-r-- 1 mzieg unixusers 1 Aug  4 21:17 foo

# verify "diff" works as expected
deedwl262 [~/work/test] mzieg 09:18 PM $ diff foo bar
1d0
< x
\ No newline at end of file

# verify "diff -w" works as expected
deedwl262 [~/work/test] mzieg 09:18 PM $ diff -w foo bar
1d0
< x
\ No newline at end of file

# verify "diff -b" works as expected
deedwl262 [~/work/test] mzieg 09:18 PM $ diff -b foo bar
1d0
< x
\ No newline at end of file

# HERE IS THE PROBLEM: diff -B does NOT work as expected
deedwl262 [~/work/test] mzieg 09:18 PM $ diff -B foo bar 

# change "foo" to a 2-byte file
deedwl262 [~/work/test] mzieg 09:18 PM $ echo  -n xy > foo

# now "diff -B" works as expected
deedwl262 [~/work/test] mzieg 09:19 PM $ diff -B foo bar 
1d0
< xy
\ No newline at end of file

Regards,

Mark Zieg
mark <at> zieg.com



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

Previous Next


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