Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: [netbsd-2] src/usr.bin/grep



Jeff Rizzo --> source-changes (2005-07-10 20:40:16 +0000):
> 
> Module Name:  src
> Committed By: riz
> Date:         Sun Jul 10 20:40:16 UTC 2005
> 
> Modified Files:
>       src/usr.bin/grep [netbsd-2]: binary.c
> 
> Log Message:
> Pull up revision 1.3 via patch (requested by mlelstv in ticket #2044):
> PR/29806: Michael Van Elst: Off by one in code.
> While I am there:
>       - factor out the binary test to an inline function.
>       - use size_t where appropriate.
>       - check for <= 0 in gzread; it returns -1 on error.
> 
> 
> To generate a diff of this commit:
> cvs rdiff -r1.1.1.2 -r1.1.1.2.4.1 src/usr.bin/grep/binary.c
> 
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.

This is not what was requested in ticket #2044 and breaks the build.
The attached patch should fix this.


Cheers, Jukka

-- 
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~
Index: usr.bin/grep/binary.c
===================================================================
RCS file: /cvsroot/src/usr.bin/grep/binary.c,v
retrieving revision 1.1.1.2.4.1
diff -u -r1.1.1.2.4.1 binary.c
--- usr.bin/grep/binary.c       10 Jul 2005 20:40:16 -0000      1.1.1.2.4.1
+++ usr.bin/grep/binary.c       10 Jul 2005 22:15:50 -0000
@@ -70,11 +70,12 @@
        if (gzseek(f, 0L, SEEK_SET) == -1)
                return 0;
 
-       if ((m = gzread(f, buf, BUFFER_SIZE)) <= 0)
+       if ((m = gzread(f, buf, BUFFER_SIZE)) == 0)
                return 0;
 
        for (i = 0; i < m; i++)
-               if (!okchar(buf[i]))
+               if (!isprint(buf[i]) && !isspace(buf[i]) &&
+                   buf[i] != line_endchar)
                        return 1;
 
        gzrewind(f);


Home | Main Index | Thread Index | Old Index