Article View: gnu.utils.bug
Article #619diff: allow a few control chars in an ascii file
From: gnu
Date: Tue, 11 Aug 1992 15:40
Date: Tue, 11 Aug 1992 15:40
61 lines
2673 bytes
2673 bytes
GNU diff wouldn't compare formatted "info" files, so I made this change.
It will now ignore the ^_'s between nodes, if they are <1.5% of the file.
A split info database's main file will have a large preponderance of
\177's (one per line, roughly, in the tag table) which still makes
diff think that it is a binary file.
Does anyone know why tag tables in `info' files use \177 to delimit
the node name from its offset? Certainly ',' could be used, since it
is the delimiter of node names in an @node command. Or the offset
could simply by the last number on the line (everything else is the
node name). This would require simple changes in makeinfo.c, info.c,
and the Emacs info reader, which I'd be willing to make.
John Gilmore
diff -u -r1.1.1.4 io.c
--- 1.1.1.4 1991/02/12 07:24:57
+++ io.c 1992/08/12 03:41:23
@@ -31,7 +31,10 @@
/* Check for binary files and compare them for exact identity. */
-/* Return 1 if BUF contains a non text character.
+/* Return 1 if BUF is a binary file.
+ We use a heuristic that allows a few odd control characters through
+ (such as used in RMAIL or Info files) but rejects files that have
+ more than a small percentage of control chars.
SIZE is the number of characters in BUF. */
static int
@@ -74,9 +77,13 @@
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
};
+ int maxallowed = 1 + ((unsigned)size) / 64; /* Allow 1.5% control chars */
+ int binchars = 0;
+
while (--size >= 0)
if (!textchar[*buf++ & 0377])
- return 1;
+ if (++binchars > maxallowed)
+ return 1;
return 0;
}
===================================================================
diff -u -r1.12 ChangeLog
--- 1.12 1992/07/04 14:59:37
+++ ChangeLog 1992/08/12 05:19:11
@@ -1,3 +1,10 @@
+Tue Aug 11 22:18:06 1992 John Gilmore (gnu at cygnus.com)
+
+ * io.c (binary_file_p): Use heuristic to avoid declaring info
+ files as binary files. Allow about 1.5% non-printing
+ characters (in info's case, ^_). This still loses for tag
+ tables, which are obnoxiously full of ^?'s.
+
Sat Jul 4 07:49:43 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
* diff.h: protect INT_MAX, CHAR_BIT, TRUE, FALSE from redefinition
Technical Details
Message-ID:
<9208120540.AA03791@cygnus.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!cygnus.com!gnuShow Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug Path: arc1-ca.pugleaf.net!sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!cygnus.com!gnu From: gnu@cygnus.com Subject: diff: allow a few control chars in an ascii file Message-ID: <9208120540.AA03791@cygnus.com> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Tue, 11 Aug 1992 15:40:58 GMT Approved: bug-gnu-utils@prep.ai.mit.edu Lines: 62