GNU bug report logs - #29311
Byte comparison from cmp diffutils

Previous Next

Package: diffutils;

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

Date: Wed, 15 Nov 2017 23:07:01 UTC

Severity: normal

To reply to this bug, email your comments to 29311 AT debbugs.gnu.org.

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#29311; Package diffutils. (Wed, 15 Nov 2017 23:07:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "s3gmentationfault <at> gmail.com" <s3gmentationfault <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-diffutils <at> gnu.org. (Wed, 15 Nov 2017 23:07:02 GMT) Full text and rfc822 format available.

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

From: "s3gmentationfault <at> gmail.com" <s3gmentationfault <at> gmail.com>
To: bug-diffutils <at> gnu.org
Subject: Byte comparison from cmp diffutils
Date: Wed, 15 Nov 2017 23:44:29 +0100
Hi, i write this message because cmp command from diffutils give an 
unexpected result if is used on binary files:
if we try to compare two different files (not symlink, not hardlink 
etc..), cmp say that the differ from 42 byte.

~ > LC_ALL=C cmp /usr/bin/g++ /usr/bin/gcc
/usr/bin/g++ /usr/bin/gcc differ: char 42, line 1

During a discussion another member convinced me to try hexdump for do 
that  comparison than i have see that those file differ for many bytes 
then 42, so i have try to write a program for do that, just for sure 
(the program is silly i have also forget to return EXIT_SUCCESS, and as 
default if it find a different byte the consider all other byte 
different but is only for this demonstration)
src: https://arin.ga/swsNn1


~ > CFLAGS=-O3 make diffbyte_gcc && ./diffbyte_gcc
they diff by: 766087 byte

so something absolutely does not work:
some clarifications: I have see just now that using C as language it say 
char, but in my language it say "byte" ("/bin/g++ /bin/gcc differenza: 
byte 42, riga 1").
However that is indifferent since in manpage it use only "byte" term, so 
i expect that it compare bytes, not only ascii text; The manpages at 
description say:  "Compare two files byte by byte".


For do other example, the wc command with -c option really counts the bytes:

~ > printf "\u2592"|wc -c
3

~ > printf "ciao\0x8" | wc -c
7


and (except for the sparse files) also du and wc report the same result 
with binary files:

~ > du -b /bin/gcc
993584  /bin/gcc

~ > wc -c /bin/gcc
993584 /bin/gcc


From info i read:
The 'cmp' command compares two files, and if they differ, tells the 
first byte and line number where they differ or reports that one file is 
a prefix of the other.
Bytes and lines are numbered starting with 1. The arguments of 'cmp' are 
as follows:

I do not know if it is meant that the comparison stops at the first line 
or rather when one of the two buffers differs from the other but 
manpages and program options say that it compare byte
so it should do




Information forwarded to bug-diffutils <at> gnu.org:
bug#29311; Package diffutils. (Thu, 16 Nov 2017 00:15:02 GMT) Full text and rfc822 format available.

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

From: "s3gmentationfault <at> gmail.com" <s3gmentationfault <at> gmail.com>
To: 29311 <at> debbugs.gnu.org
Subject: Byte comparison from cmp diffutils
Date: Thu, 16 Nov 2017 00:24:57 +0100
Hi, i write this message regarding to my previous bug report, i have see 
just now that posix section of manpages say:
"The cmp utility shall write no output files are the same. Under default 
options, if they differ, it  shall write tostandard  output the byte and 
line number at which the first difference occurred. Bytes and lines 
shall be numbered beginning with 1."

so now it's all clare.




This bug report was last modified 7 years and 213 days ago.

Previous Next


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