grep reports Binary file xxx matches

Yesterday I ran into weird problem that grep wouldn’t find some functions in C source files, which drove me nut. ‘It can’t be or can it?’ I hardly do C programming and my confidence is low nowdays. I forgot how to create Makefile for building source codes.

I was looking for which source file contains tesselate() function running grep commands and was seeing empty console.

$ grep -n tesselate *.c
Binary file dome_math.c matches

Why couldn’t I think about the message seriouslY? dome_math.c has to be a text file and I knew it.

There was a bug report.
bug#19388: grep 2.21-1 identifies iso encoded text files as binary
https://lists.gnu.org/archive/html/bug-grep/2014-12/msg00049.html

Until I test new version of grep, I’ll use -a option to search words in source files.


$ file *.c
3ds_utils.c: C source, ISO-8859 text
dome_3ds.c: C source, ASCII text
dome.c: C source, ASCII text
dome_cover.c: C source, ASCII text
dome_file.c: C source, ASCII text
dome_layout.c: C source, ASCII text
dome_math.c: C source, ISO-8859 text
dome_struts.c: C source, ASCII text
main.c: C source, ASCII text
utils.c: C source, ASCII text

$ grep -a tesselate dome_math.c
static void tesselate1(const Dome *in, Face face, int f, Dome *out,
tesselate(const Dome *in, Dome *out, int f)
tesselate1(in, in->faces[i], f, out, &fcount, could not be a binary file. &vcount, &ecount);
tesselate1(const Dome *in, Face face, int f, Dome *out,
fprintf(stderr, “Internal error: out of faces in tesselate\n”);
fprintf(stderr, “Internal error: out of vertices in tesselate\n”);

$ grep tesselate dome_math.c
Binary file dome_math.c matches

About janpenguin

Email: janpenguin [at] riseup [dot] net Every content on the blog is made by Free and Open Source Software in GNU/Linux.
This entry was posted in GNU/Linux and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s