Subject: Re: Recursive grep (where is limfree defined?)
To: None <current-users@NetBSD.ORG>
From: None <thieleke@icaen.uiowa.edu>
List: current-users
Date: 01/24/1996 02:20:35
> > GREP(1) GREP(1)
> > .
> > .
> > .
> > -a Don't search in binary files.
>
> Interesting... What heuristic do you use to tell if a file is
> binary? This is actually a bit harder than one might think...
I don't use any heuristic - the author of the patch appears to search the
file for non-printable character, see the isBinaryFile() function:
int isBinaryFile()
/* look for non-printable chars */
for(i = 0; i < n; i++)
if (!isprint(buf[i]) && !isspace(buf[i]))
return(1);
There might be better ways of doing it, but this appears to be a fairly
cheap and easy way to do it, assuming that most binary files would have a
non-printable character early on, and most text files are consist of only
printable characters.
I couldn't find a binary large enough to crash grep (without cooking up a
contrived example) on my system, so I didn't fully test this option.
Just a suggestion to those interested (one way or another) - apply the
patch, explore the source, and try out the binary.
Jeff Thieleke