Article View: gnu.utils.bug
Article #563Better binary-file checking for gnu diff
From: Wayne Davison
Date: Mon, 27 Nov 1989 10:05
Date: Mon, 27 Nov 1989 10:05
39 lines
1711 bytes
1711 bytes
Here's a simple little change that I've been applying to each new release of
gnu diff that comes out. It extends the check for a binary file to include
a file with 0's in it. I've had binaries in the past that didn't have any
bytes with the 0200 bit set (in the quantity checked by gnu diff), but had
plenty of 0's. Any reason NOT to do this?
This diff generated from version 1.12:
*** io.c.orig Sun Sep 17 23:58:49 1989
--- io.c Sat Nov 25 14:26:18 1989
***************
*** 32,36 ****
/* Check for binary files and compare them for exact identity. */
! /* Return 1 if BUF contains a character with the 0200 bit set.
SIZE is the number of characters in BUF. */
--- 32,36 ----
/* Check for binary files and compare them for exact identity. */
! /* Return 1 if BUF contains a 0 or a character with the 0200 bit set.
SIZE is the number of characters in BUF. */
***************
*** 41,45 ****
{
while (--size >= 0)
! if (*buf++ & 0200)
return 1;
return 0;
--- 41,45 ----
{
while (--size >= 0)
! if (!*buf || *buf++ & 0200)
return 1;
return 0;
--
Wayne Davison \ /| / /| \/ /| /(_) davison@drivax.UUCP
(_)/ |/ /\| / / |/ \ ...!amdahl!drivax!davison
Technical Details
Message-ID:
<257106ED.5467@drivax.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!uunet!amdahl!drivax!davisonShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!uunet!amdahl!drivax!davison From: davison@drivax.UUCP (Wayne Davison) Newsgroups: gnu.utils.bug Subject: Better binary-file checking for gnu diff Message-ID: <257106ED.5467@drivax.UUCP> Date: 27 Nov 89 10:05:33 GMT Reply-To: davison@drivax.UUCP (Wayne Davison) Organization: Digital Research, Monterey CA Lines: 39