GNU bug report logs - #18402
Wrong output for single character files without newline

Previous Next

Package: diffutils;

Reported by: Eric Blake <eblake <at> redhat.com>

Date: Wed, 3 Sep 2014 21:05:02 UTC

Severity: normal

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: Eric Blake <eblake <at> redhat.com>
Subject: bug#18402: closed (Re: [bug-diffutils] bug#18402: Wrong output
 for single character files without newline)
Date: Wed, 03 Sep 2014 23:07:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#18402: Wrong output for single character files without newline

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

-- 
18402: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18402
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: Eric Blake <eblake <at> redhat.com>, navin <at> smriti.com, 
 Matt Johnson <mj1856 <at> hotmail.com>, 18402-done <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#18402: Wrong output for single character
 files without newline
Date: Wed, 03 Sep 2014 16:05:55 -0700
[Message part 3 (text/plain, inline)]
Thanks for reporting that.  I installed the attached 3 patches; patch #2 
should fix the bug.
[0001-diff-fix-performance-bug-with-prefix-computation.patch (text/plain, attachment)]
[0002-diff-fix-bug-with-diff-B-and-incomplete-lines.patch (text/plain, attachment)]
[0003-doc-mention-diff-B-fix-in-NEWS.patch (text/plain, attachment)]
[Message part 7 (message/rfc822, inline)]
From: Eric Blake <eblake <at> redhat.com>
To: Navin Kabra <navin <at> smriti.com>, bug-gnu-utils <at> gnu.org,
 bug-diffutils <at> gnu.org
Subject: Re: Wrong output for single character files without newline
Date: Wed, 03 Sep 2014 15:03:44 -0600
[Message part 8 (text/plain, inline)]
[adding bug-diffutils, as requested by diff --help]

On 09/03/2014 04:17 AM, Navin Kabra wrote:
> Consider this:
> 
>     echo -n a > /tmp/a
>     echo -n b > /tmp/b
>     diff -B /tmp/a /tmp/b

'echo -n' is non-portable.  Please get used to using 'printf' instead.

> 
> Clearly, the two files are different, yet, diff seems to think that the
> files are identical. I've managed to reproduce this problem on Ubuntu
> 14.04 with diffutils 3.3, on CloudLinux 5.10 with diffutils 2.8.1, and
> also Ubuntu 10.04 with diffutils 2.8.1.
> 
> If I don't use the -B option, the problem goes away. If the files do end
> with a newline, the problem goes away. If the files contain more than 1
> character, the problem goes away. If combined with *some* of the other
> options (e.g. -e or -y) the problem goes away.

Actually, I couldn't reproduce -y making the problem go away:

$ ./src/diff -By <(printf a) <(printf b)
a								b
$ echo $?
0

Thanks for the extensive analysis; I can confirm that this bug is still
present in the latest diffutils.git sources, although I have not
personally hunted for the culprit line of code yet.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 10 years and 340 days ago.

Previous Next


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