Subject: Re: [bug-diffutils] bug#24154: bug in 'diff -B'

From: Jim Meyering <[email-masked]>
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]
<[email-masked]> 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 <[email-masked]>
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.