It actually makes the binaries smaller, the code easier to read
(gems like "val == true", "val == false" are gone) and actually
predictable in the sense of that we actually know what we're
working with (one bitwise operator was quite adventurous and
should now be fixed).
This is also more consistent with the other suckless projects
around which don't use boolean types.
Otherwise, a pattern with a '$' anchor will never match and POSIX says that
"By default, an input line shall be selected if any pattern ... matches any
part of the line excluding the terminating <newline>"
improvements:
- improve statuscode behaviour
- don't exit if a file in a series fails. exit 2 if an error occured
in a file series. don't exit if there is a read error (like: grep
input file is a directory).
- use agetline instead of agets().
with the simple test: time seq 1 100000000 | grep 'a'
its 12 seconds (from 24 seconds) on my machine.
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
This reverts commit d9a098ae6bc07188cbaefcd188e5911dec41815d.
Conflicts:
grep.c
Hiltjo Posthuma <hiltjo@codemadness.org> said:
(Re)compiling the regex for each line doesn't make sense (imho) and
slows it down a lot.
A simple test:
time seq 1 100000000 | grep 'a'
sbase grep (before patch):
0m22.21s real 0m0.00s user 0m0.00s system
sbase grep (after patch):
2m16.28s real 0m0.00s user 0m0.00s system
coreutils grep:
0m1.15s real 0m0.00s user 0m0.00s system
So the patch should be reverted I think.