Enabled this new feature with the makefile variable GREP_LIBZ. If
you don't like it, compile with `make GREP_LIBZ='.
grep + zlib has several advantages:
- the shell script zgrep(1) will be basically a one line
exec grep -Z "$@"
- no shell script, no bugs. The current zgrep implementations
have many bugs and some grep options are no supported.
- no shell script, no security risks.
- it is a magnitude faster than a shell script
Also fixed:
0 -> STDIN_FILENO
Close a file descriptor only if the open call was successfully. It does
not hurt for the open(2) function, but the gzclose(3) function
died in free() to free up (not) allocated memory.
search 'pattern' in whole file 'file', from top to bottom. This is
not necessary; if grep found 'pattern' it can stop further searching
in file 'file'.
Example:
$ time ./grep-old -q Adam /usr/share/dict/*
1.93 real 1.05 user 0.85 sys
$ time ./grep-new -q Adam /usr/share/dict/*
0.14 real 0.06 user 0.06 sys