#
1.67 |
|
26-Jun-2022 |
op |
add --null to usage() forgot in previous commit. reminded by jmc@, thanks!
|
#
1.66 |
|
26-Jun-2022 |
op |
grep: add --null flag
makes grep print an ASCII NUL byte after the file name to make the output unambiguous even in the presence of file names with funny characters.
A previous iteration of this diff was improved by benno@ and tedu@ and discussed also with sthen@ and deraadt@. deraadt@ also improved the manpage changes in this version of the diff.
OK deraadt@
|
Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
|
#
1.65 |
|
23-Jul-2020 |
martijn |
Change line counter from int to unsigned long long to reduce overflow. In case unsigned long long is miraculously still too small add an additional overflow detection so we stop counting and add a marker to couter output.
Input on earlier diff guenther@ OK millert
|
Revision tags: OPENBSD_6_7_BASE
|
#
1.64 |
|
03-Dec-2019 |
jca |
With -R and an implicit ".", don't prepend file paths with "./"
Looks nicer and matches the output of GNU grep. ok millert@ deraadt@ visa@ miod@
|
#
1.63 |
|
02-Dec-2019 |
jca |
With -R assume that "." was passed instead of printing a warning
Saner default behavior that matches GNU grep. Diff from miod@, support from espie@, ok visa@ millert@
|
Revision tags: OPENBSD_6_6_BASE
|
#
1.62 |
|
07-Oct-2019 |
tedu |
add --label to usage. thx jmc
|
#
1.61 |
|
07-Oct-2019 |
tedu |
two compat features to allow the zstdgrep script to work. add --label option to prefix the output instead of filename. allow using - to mean stdin. ok deraadt
|
#
1.60 |
|
18-Jul-2019 |
schwarze |
Delete documentation of --max-count, which is merely an alias of the documented -m. As a rule, we only document long options when users can't avoid them because they lack a short version.
As suggested by tedu@, as an exception, leave --context documented because -C is awkward in so far as it takes an optional option argument, which is fragile and error-prone and hence generally discouraged, including by POSIX.
Two years ago, kettenis@, deraadt@, and tedu@ all agreed that this is what should be done, and jmc@ was happy to accept the direction, but somehow everybody forgot to commit.
|
Revision tags: OPENBSD_6_5_BASE
|
#
1.59 |
|
31-Jan-2019 |
tedu |
convert fgetln to getline. this improves portability and sets a good better example for other code to follow. in the common case, grep uses mmap anyway (so no functional change). despite fgetln doing sneaky things with stdio internals, preliminary analysis by lauri suggests this may actually reduce the number of allocations. from Lauri Tirkkonen.
|
#
1.58 |
|
23-Jan-2019 |
tedu |
rework grep_open to be more careful about directories. cleaner, but should be no functional change. from Lauri Tirkkonen
|
Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
|
#
1.57 |
|
10-Dec-2017 |
jmc |
- add max-count to SYNOPSIS - list long options with short, where they have an equivalent - sync usage() - minor tweaks
|
#
1.56 |
|
09-Dec-2017 |
pirofti |
Add support for the non-standard grep -m extension.
grep -m num stops after a maximum of num matches are found. We support -m0 to match GNU behaviour, but we do not allow negative numbers.
Manpage help from jmc@, OK deraadt@.
|
Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
|
#
1.55 |
|
28-Nov-2015 |
gsoares |
fix exit status on pledge(2) error, where it should be >1
OK millert@ deraadt@
|
#
1.54 |
|
09-Oct-2015 |
deraadt |
Change all tame callers to namechange to pledge(2).
|
#
1.53 |
|
03-Oct-2015 |
deraadt |
grep only opens files read-only, reads via stdio or other methods, performs computation, and outputs result to stdout. (note: in the tame model, malloc is implicit because stdio needs it, and mmap is implicit since malloc needs it; libz is satisfied by this environment also).
this tame change consists of 1 line, setting "stdio rpath" before getopt. this protection is fairly strict. grep could be improved further by computing a wpathlist based on argv, keeping -R in mind. feel free to take a shot at it.
grep was an early target of capsicum also. know anyone running capsicum grep?
ok doug
|
#
1.52 |
|
27-Aug-2015 |
dlg |
use strtonum to parse the number of lines of context.
this provides better error messages.
ok deraadt@ guenther@
|
Revision tags: OPENBSD_5_8_BASE
|
#
1.51 |
|
30-Apr-2015 |
millert |
Add warning when user specifies -R but no files, like GNU grep. OK schwarze@ ian@
|
#
1.50 |
|
16-Mar-2015 |
millert |
Don't include limits.h or sys/limits.h since grep.h already does it for us.
|
Revision tags: OPENBSD_5_7_BASE
|
#
1.49 |
|
10-Jan-2015 |
tedu |
1. They're flags, not counters. Set to one instead of incrementing. 2. The G flag is useless and never checked. Remove it. ok millert
|
#
1.48 |
|
01-Dec-2014 |
deraadt |
use reallocarray()
|
#
1.47 |
|
26-Nov-2014 |
millert |
Prefer setvbuf() to setlinebuf() for portability; ok deraadt@
|
#
1.46 |
|
26-Nov-2014 |
millert |
Make option string/struct const (since it is...). I've had this in my tree for ages.
|
Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
|
#
1.45 |
|
29-Dec-2012 |
millert |
Fix exit status when there is an error reading a file. Reported by Jeramey Crawford, fix adapted from FreeBSD. OK guenther@
|
Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
|
#
1.44 |
|
08-Jul-2011 |
tedu |
add support for -o to only print the match. reminded this was useful by ajcoutot
|
#
1.43 |
|
04-Mar-2011 |
tedu |
add -H (opposite of -h) to always print name. ok deraadt millert
|
Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
|
#
1.42 |
|
02-Jul-2010 |
tedu |
Remove the "fast" grep code if SMALL. This has the side effect of breaking fgrep -w, but oh well. ok deraadt millert
|
#
1.41 |
|
20-Apr-2010 |
jacekm |
Fix "grep -e foo -w" crash. The problem lies in 'e' getopt clause calling add_pattern, which in turn assumes that the getopt phase has already finished.
OK otto@
|
#
1.40 |
|
05-Apr-2010 |
tedu |
remove some non-POSIX standard non-GNU defacto standard options, mostly relating to symlinks that you can get with find. And a bonus fts flag fix. With a small tweak by guenther. ok deraadt guenther jmc millert nicm
|
Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
|
#
1.39 |
|
02-Sep-2007 |
deraadt |
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
|
Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
|
#
1.38 |
|
13-Feb-2007 |
kili |
- Be explicit on command line checking, instead of relying on patterns, which may be NULL (e.g. -e ''). - let add_pattern() decide how to deal with empty patterns, don't do magic in read_patterns().
This unbreaks stuff like grep -e '', and makes grep -f <file> more POSIX compliant. Semantics for grep -f /dev/null (or any other empty file) may be questionable, but this case isn't specified by POSIX, and matching nothing at all seems to be sane.
Thanks to otto@, who mentioned potential problems related to the -x option with the first patch i sent.
ok jaredy@ (some time ago), otto@, millert@
|
#
1.37 |
|
02-Nov-2006 |
ray |
Check length before checking index of len - 1.
OK moritz@.
|
#
1.36 |
|
26-Sep-2006 |
jaredy |
Allow zero-length patterns with -x so
$ grep -x ""
matches empty lines as reported on misc@ by Martin Marusak <marusak@fhpv.unipo.sk>. Initial diff by otto@ with tweaks by me.
ok otto
|
Revision tags: OPENBSD_4_0_BASE
|
#
1.35 |
|
07-Mar-2006 |
otto |
Break patterns containing newlines into multiple patterns like POSIX says. Report by Ralf dot Wildenhues at gmx dot de; testing by jmc@ ok beck@ millert@
|
Revision tags: OPENBSD_3_9_BASE
|
#
1.34 |
|
09-Feb-2006 |
otto |
delint; remove redundant vars and functions; ok jaredy@
|
Revision tags: OPENBSD_3_8_BASE
|
#
1.33 |
|
03-Apr-2005 |
jaredy |
Make the processing of patterns collected from files specified by -f delayed so options that affect pattern-building (such as -w) can be applied evenly to all such patterns.
ok and help otto, ok millert
|
#
1.32 |
|
03-Apr-2005 |
otto |
Protect begin and end of word markers added to the pattern when using the -w option with parentheses, to avoid operators in the expressions binding to the markers. Compare [[:<:]]foo|bar[[:>:]] and [[:<:]](foo|bar)[[:>:]]. Problem spotted by aaron@; ok millert@ aaron@ jaredy@
|
Revision tags: OPENBSD_3_7_BASE
|
#
1.31 |
|
03-Oct-2004 |
otto |
Remove block based mmap optimization. There are newline problems (PR 3940, 3941) which can be fixed, but if a match starts at the end of a block and continues into the next block, no match will be found. Measurements by millert@ showed that the improvements of this optimization are non-measurable anyway. Diff from Alexander Taler.
ok millert@
|
#
1.30 |
|
28-Sep-2004 |
jmc |
various fixes to make this page a bit clearer and hopefully a bit more helpful;
this includes some ideas/fixes from otto and jared;
|
Revision tags: OPENBSD_3_6_BASE
|
#
1.29 |
|
05-Aug-2004 |
deraadt |
spacing
|
#
1.28 |
|
07-May-2004 |
millert |
Add a new past path for fgrep that is just a simplified version of fastcomp. This makes fgrep faster and fixes the -w flag w/ fgrep. Also remove free_patterns() since calling free right before exit is silly. Problem noticed by espie@
|
#
1.27 |
|
02-Apr-2004 |
otto |
Implement --line-buffered ok millert@ tedu@
|
Revision tags: OPENBSD_3_5_BASE
|
#
1.26 |
|
04-Feb-2004 |
millert |
Fix anchors (^ or $) in -w mode broken by the last commit's -w overhaul. With this change we pass the updated regress. Tested and OK by ho@
|
#
1.25 |
|
25-Jan-2004 |
millert |
Previously, in -w mode, for each match on a line grep would check to see if the match was on a word boundary. However, this missed lines where the first match was not on a word boundary but a subsequent match was. Problem originally spotted by miod@
We fix this by using the [[:<:]] and [[:>:]] character classes for the slow path and by checking the word boundaries in grep_search() for the fast path instead of doing the checks after running regexec() or grep_search().
With this change, grep passes the new regress tests 15 and 16. problem originally spotted by espie@.
|
#
1.24 |
|
11-Dec-2003 |
mcbride |
Sync usage() with SYNOPSIS in grep(1).
ok deraadt@ jmc@
|
Revision tags: OPENBSD_3_4_BASE
|
#
1.23 |
|
07-Sep-2003 |
millert |
Fix "grep -number" support for multi-digit numbers. At issue is the fact that optind refers to the *next* argument to be consumed by getopt(), not the current one. This means we have to keep track of when we are working with a new argv entry by hand. OK hugh@
|
#
1.22 |
|
16-Jul-2003 |
millert |
When reallocing pattern, use sizeof(*pattern) not sizeof(int). Fixes a problem on sparc64 where sizeof(int) != sizeof(pointer). Based on a patch from Brian Poole; tedu@ OK
|
#
1.21 |
|
14-Jul-2003 |
millert |
range-check numeric arguments (-num, -A num, -B num)
|
#
1.20 |
|
10-Jul-2003 |
millert |
grep should exit(2) on error, not exit(1) (1 means no matches found). deraadt@ OK
|
#
1.19 |
|
10-Jul-2003 |
deraadt |
knf
|
#
1.18 |
|
10-Jul-2003 |
millert |
Fix parsing of -NUMBER. We now do things a digit at a time and keep track of what the last char from getopt was as well as the previous value of optind so we know when a new number has started.
|
#
1.17 |
|
25-Jun-2003 |
millert |
o remove useless cast to int from gzread() call o maxPatternLen should be size_t since that's what it is compared against o remove useless casts of NULL to various pointer types
|
#
1.16 |
|
24-Jun-2003 |
tedu |
actually do fgrep. -G -F and -E are now mutally exclusive, and override the program name as expected. ok millert@
|
#
1.15 |
|
23-Jun-2003 |
tedu |
strncpy -> memcpy per deraadt suggestion. also add a note why we can't use strlcpy.
|
#
1.14 |
|
23-Jun-2003 |
tedu |
go back to using strncpy. for long patterns, strlcpy reads too much of a potentially nontermined src.
|
#
1.13 |
|
23-Jun-2003 |
tedu |
faster grep for simple patterns. derived from a patch by sean farley. this makes searching for constant strings much faster by avoiding regex. ok deraadt@
|
#
1.12 |
|
23-Jun-2003 |
deraadt |
minor tweaks
|
#
1.11 |
|
23-Jun-2003 |
tedu |
use strlcpy, not strncpy. ok deraadt@ millert@
|
#
1.10 |
|
23-Jun-2003 |
tedu |
spelling
|
#
1.9 |
|
23-Jun-2003 |
tedu |
better detetection/handling of binary files. make -a do the right thing, doc and implement -U, -I. add --help and --mmap for compatibility. some other minor fixes.
some from NetBSD. ok deraadt@
|
#
1.8 |
|
22-Jun-2003 |
tedu |
use __progname instead of progname. ok deraadt
|
#
1.7 |
|
22-Jun-2003 |
deraadt |
fix usage
|
#
1.6 |
|
22-Jun-2003 |
deraadt |
proper $OpenBSD$
|
#
1.5 |
|
22-Jun-2003 |
deraadt |
-DNOZ flag to be used by install media for removing z*grep support, if needed. (and knf)
|
#
1.4 |
|
22-Jun-2003 |
deraadt |
support z{e,f}grep
|
#
1.3 |
|
22-Jun-2003 |
deraadt |
freegrep 0.16
|
Revision tags: OPENBSD_3_3_BASE
|
#
1.2 |
|
16-Feb-2003 |
cloder |
Fix format string bug. I believe this grep is currently not used (in favor of the GNU version), but it gets fixed anyways. ok mickey@
|
Revision tags: OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE
|
#
1.1 |
|
21-Sep-2001 |
deraadt |
complete grep clone by harding@motd.ca; everything is there, but it is slow because libc regexp is slow. Anyone out there have the balls to sit down and optimize libc regexp?
|
#
1.65 |
|
23-Jul-2020 |
martijn |
Change line counter from int to unsigned long long to reduce overflow. In case unsigned long long is miraculously still too small add an additional overflow detection so we stop counting and add a marker to couter output.
Input on earlier diff guenther@ OK millert
|
Revision tags: OPENBSD_6_7_BASE
|
#
1.64 |
|
03-Dec-2019 |
jca |
With -R and an implicit ".", don't prepend file paths with "./"
Looks nicer and matches the output of GNU grep. ok millert@ deraadt@ visa@ miod@
|
#
1.63 |
|
02-Dec-2019 |
jca |
With -R assume that "." was passed instead of printing a warning
Saner default behavior that matches GNU grep. Diff from miod@, support from espie@, ok visa@ millert@
|
Revision tags: OPENBSD_6_6_BASE
|
#
1.62 |
|
07-Oct-2019 |
tedu |
add --label to usage. thx jmc
|
#
1.61 |
|
07-Oct-2019 |
tedu |
two compat features to allow the zstdgrep script to work. add --label option to prefix the output instead of filename. allow using - to mean stdin. ok deraadt
|
#
1.60 |
|
18-Jul-2019 |
schwarze |
Delete documentation of --max-count, which is merely an alias of the documented -m. As a rule, we only document long options when users can't avoid them because they lack a short version.
As suggested by tedu@, as an exception, leave --context documented because -C is awkward in so far as it takes an optional option argument, which is fragile and error-prone and hence generally discouraged, including by POSIX.
Two years ago, kettenis@, deraadt@, and tedu@ all agreed that this is what should be done, and jmc@ was happy to accept the direction, but somehow everybody forgot to commit.
|
Revision tags: OPENBSD_6_5_BASE
|
#
1.59 |
|
31-Jan-2019 |
tedu |
convert fgetln to getline. this improves portability and sets a good better example for other code to follow. in the common case, grep uses mmap anyway (so no functional change). despite fgetln doing sneaky things with stdio internals, preliminary analysis by lauri suggests this may actually reduce the number of allocations. from Lauri Tirkkonen.
|
#
1.58 |
|
23-Jan-2019 |
tedu |
rework grep_open to be more careful about directories. cleaner, but should be no functional change. from Lauri Tirkkonen
|
Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
|
#
1.57 |
|
10-Dec-2017 |
jmc |
- add max-count to SYNOPSIS - list long options with short, where they have an equivalent - sync usage() - minor tweaks
|
#
1.56 |
|
09-Dec-2017 |
pirofti |
Add support for the non-standard grep -m extension.
grep -m num stops after a maximum of num matches are found. We support -m0 to match GNU behaviour, but we do not allow negative numbers.
Manpage help from jmc@, OK deraadt@.
|
Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
|
#
1.55 |
|
28-Nov-2015 |
gsoares |
fix exit status on pledge(2) error, where it should be >1
OK millert@ deraadt@
|
#
1.54 |
|
09-Oct-2015 |
deraadt |
Change all tame callers to namechange to pledge(2).
|
#
1.53 |
|
03-Oct-2015 |
deraadt |
grep only opens files read-only, reads via stdio or other methods, performs computation, and outputs result to stdout. (note: in the tame model, malloc is implicit because stdio needs it, and mmap is implicit since malloc needs it; libz is satisfied by this environment also).
this tame change consists of 1 line, setting "stdio rpath" before getopt. this protection is fairly strict. grep could be improved further by computing a wpathlist based on argv, keeping -R in mind. feel free to take a shot at it.
grep was an early target of capsicum also. know anyone running capsicum grep?
ok doug
|
#
1.52 |
|
27-Aug-2015 |
dlg |
use strtonum to parse the number of lines of context.
this provides better error messages.
ok deraadt@ guenther@
|
Revision tags: OPENBSD_5_8_BASE
|
#
1.51 |
|
30-Apr-2015 |
millert |
Add warning when user specifies -R but no files, like GNU grep. OK schwarze@ ian@
|
#
1.50 |
|
16-Mar-2015 |
millert |
Don't include limits.h or sys/limits.h since grep.h already does it for us.
|
Revision tags: OPENBSD_5_7_BASE
|
#
1.49 |
|
10-Jan-2015 |
tedu |
1. They're flags, not counters. Set to one instead of incrementing. 2. The G flag is useless and never checked. Remove it. ok millert
|
#
1.48 |
|
01-Dec-2014 |
deraadt |
use reallocarray()
|
#
1.47 |
|
26-Nov-2014 |
millert |
Prefer setvbuf() to setlinebuf() for portability; ok deraadt@
|
#
1.46 |
|
26-Nov-2014 |
millert |
Make option string/struct const (since it is...). I've had this in my tree for ages.
|
Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
|
#
1.45 |
|
29-Dec-2012 |
millert |
Fix exit status when there is an error reading a file. Reported by Jeramey Crawford, fix adapted from FreeBSD. OK guenther@
|
Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
|
#
1.44 |
|
08-Jul-2011 |
tedu |
add support for -o to only print the match. reminded this was useful by ajcoutot
|
#
1.43 |
|
04-Mar-2011 |
tedu |
add -H (opposite of -h) to always print name. ok deraadt millert
|
Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
|
#
1.42 |
|
02-Jul-2010 |
tedu |
Remove the "fast" grep code if SMALL. This has the side effect of breaking fgrep -w, but oh well. ok deraadt millert
|
#
1.41 |
|
20-Apr-2010 |
jacekm |
Fix "grep -e foo -w" crash. The problem lies in 'e' getopt clause calling add_pattern, which in turn assumes that the getopt phase has already finished.
OK otto@
|
#
1.40 |
|
05-Apr-2010 |
tedu |
remove some non-POSIX standard non-GNU defacto standard options, mostly relating to symlinks that you can get with find. And a bonus fts flag fix. With a small tweak by guenther. ok deraadt guenther jmc millert nicm
|
Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
|
#
1.39 |
|
02-Sep-2007 |
deraadt |
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
|
Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
|
#
1.38 |
|
13-Feb-2007 |
kili |
- Be explicit on command line checking, instead of relying on patterns, which may be NULL (e.g. -e ''). - let add_pattern() decide how to deal with empty patterns, don't do magic in read_patterns().
This unbreaks stuff like grep -e '', and makes grep -f <file> more POSIX compliant. Semantics for grep -f /dev/null (or any other empty file) may be questionable, but this case isn't specified by POSIX, and matching nothing at all seems to be sane.
Thanks to otto@, who mentioned potential problems related to the -x option with the first patch i sent.
ok jaredy@ (some time ago), otto@, millert@
|
#
1.37 |
|
02-Nov-2006 |
ray |
Check length before checking index of len - 1.
OK moritz@.
|
#
1.36 |
|
26-Sep-2006 |
jaredy |
Allow zero-length patterns with -x so
$ grep -x ""
matches empty lines as reported on misc@ by Martin Marusak <marusak@fhpv.unipo.sk>. Initial diff by otto@ with tweaks by me.
ok otto
|
Revision tags: OPENBSD_4_0_BASE
|
#
1.35 |
|
07-Mar-2006 |
otto |
Break patterns containing newlines into multiple patterns like POSIX says. Report by Ralf dot Wildenhues at gmx dot de; testing by jmc@ ok beck@ millert@
|
Revision tags: OPENBSD_3_9_BASE
|
#
1.34 |
|
09-Feb-2006 |
otto |
delint; remove redundant vars and functions; ok jaredy@
|
Revision tags: OPENBSD_3_8_BASE
|
#
1.33 |
|
03-Apr-2005 |
jaredy |
Make the processing of patterns collected from files specified by -f delayed so options that affect pattern-building (such as -w) can be applied evenly to all such patterns.
ok and help otto, ok millert
|
#
1.32 |
|
03-Apr-2005 |
otto |
Protect begin and end of word markers added to the pattern when using the -w option with parentheses, to avoid operators in the expressions binding to the markers. Compare [[:<:]]foo|bar[[:>:]] and [[:<:]](foo|bar)[[:>:]]. Problem spotted by aaron@; ok millert@ aaron@ jaredy@
|
Revision tags: OPENBSD_3_7_BASE
|
#
1.31 |
|
03-Oct-2004 |
otto |
Remove block based mmap optimization. There are newline problems (PR 3940, 3941) which can be fixed, but if a match starts at the end of a block and continues into the next block, no match will be found. Measurements by millert@ showed that the improvements of this optimization are non-measurable anyway. Diff from Alexander Taler.
ok millert@
|
#
1.30 |
|
28-Sep-2004 |
jmc |
various fixes to make this page a bit clearer and hopefully a bit more helpful;
this includes some ideas/fixes from otto and jared;
|
Revision tags: OPENBSD_3_6_BASE
|
#
1.29 |
|
05-Aug-2004 |
deraadt |
spacing
|
#
1.28 |
|
07-May-2004 |
millert |
Add a new past path for fgrep that is just a simplified version of fastcomp. This makes fgrep faster and fixes the -w flag w/ fgrep. Also remove free_patterns() since calling free right before exit is silly. Problem noticed by espie@
|
#
1.27 |
|
02-Apr-2004 |
otto |
Implement --line-buffered ok millert@ tedu@
|
Revision tags: OPENBSD_3_5_BASE
|
#
1.26 |
|
04-Feb-2004 |
millert |
Fix anchors (^ or $) in -w mode broken by the last commit's -w overhaul. With this change we pass the updated regress. Tested and OK by ho@
|
#
1.25 |
|
25-Jan-2004 |
millert |
Previously, in -w mode, for each match on a line grep would check to see if the match was on a word boundary. However, this missed lines where the first match was not on a word boundary but a subsequent match was. Problem originally spotted by miod@
We fix this by using the [[:<:]] and [[:>:]] character classes for the slow path and by checking the word boundaries in grep_search() for the fast path instead of doing the checks after running regexec() or grep_search().
With this change, grep passes the new regress tests 15 and 16. problem originally spotted by espie@.
|
#
1.24 |
|
11-Dec-2003 |
mcbride |
Sync usage() with SYNOPSIS in grep(1).
ok deraadt@ jmc@
|
Revision tags: OPENBSD_3_4_BASE
|
#
1.23 |
|
07-Sep-2003 |
millert |
Fix "grep -number" support for multi-digit numbers. At issue is the fact that optind refers to the *next* argument to be consumed by getopt(), not the current one. This means we have to keep track of when we are working with a new argv entry by hand. OK hugh@
|
#
1.22 |
|
16-Jul-2003 |
millert |
When reallocing pattern, use sizeof(*pattern) not sizeof(int). Fixes a problem on sparc64 where sizeof(int) != sizeof(pointer). Based on a patch from Brian Poole; tedu@ OK
|
#
1.21 |
|
14-Jul-2003 |
millert |
range-check numeric arguments (-num, -A num, -B num)
|
#
1.20 |
|
10-Jul-2003 |
millert |
grep should exit(2) on error, not exit(1) (1 means no matches found). deraadt@ OK
|
#
1.19 |
|
10-Jul-2003 |
deraadt |
knf
|
#
1.18 |
|
10-Jul-2003 |
millert |
Fix parsing of -NUMBER. We now do things a digit at a time and keep track of what the last char from getopt was as well as the previous value of optind so we know when a new number has started.
|
#
1.17 |
|
25-Jun-2003 |
millert |
o remove useless cast to int from gzread() call o maxPatternLen should be size_t since that's what it is compared against o remove useless casts of NULL to various pointer types
|
#
1.16 |
|
24-Jun-2003 |
tedu |
actually do fgrep. -G -F and -E are now mutally exclusive, and override the program name as expected. ok millert@
|
#
1.15 |
|
23-Jun-2003 |
tedu |
strncpy -> memcpy per deraadt suggestion. also add a note why we can't use strlcpy.
|
#
1.14 |
|
23-Jun-2003 |
tedu |
go back to using strncpy. for long patterns, strlcpy reads too much of a potentially nontermined src.
|
#
1.13 |
|
23-Jun-2003 |
tedu |
faster grep for simple patterns. derived from a patch by sean farley. this makes searching for constant strings much faster by avoiding regex. ok deraadt@
|
#
1.12 |
|
23-Jun-2003 |
deraadt |
minor tweaks
|
#
1.11 |
|
23-Jun-2003 |
tedu |
use strlcpy, not strncpy. ok deraadt@ millert@
|
#
1.10 |
|
23-Jun-2003 |
tedu |
spelling
|
#
1.9 |
|
23-Jun-2003 |
tedu |
better detetection/handling of binary files. make -a do the right thing, doc and implement -U, -I. add --help and --mmap for compatibility. some other minor fixes.
some from NetBSD. ok deraadt@
|
#
1.8 |
|
22-Jun-2003 |
tedu |
use __progname instead of progname. ok deraadt
|
#
1.7 |
|
22-Jun-2003 |
deraadt |
fix usage
|
#
1.6 |
|
22-Jun-2003 |
deraadt |
proper $OpenBSD$
|
#
1.5 |
|
22-Jun-2003 |
deraadt |
-DNOZ flag to be used by install media for removing z*grep support, if needed. (and knf)
|
#
1.4 |
|
22-Jun-2003 |
deraadt |
support z{e,f}grep
|
#
1.3 |
|
22-Jun-2003 |
deraadt |
freegrep 0.16
|
Revision tags: OPENBSD_3_3_BASE
|
#
1.2 |
|
16-Feb-2003 |
cloder |
Fix format string bug. I believe this grep is currently not used (in favor of the GNU version), but it gets fixed anyways. ok mickey@
|
Revision tags: OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE
|
#
1.1 |
|
21-Sep-2001 |
deraadt |
complete grep clone by harding@motd.ca; everything is there, but it is slow because libc regexp is slow. Anyone out there have the balls to sit down and optimize libc regexp?
|
#
1.64 |
|
03-Dec-2019 |
jca |
With -R and an implicit ".", don't prepend file paths with "./"
Looks nicer and matches the output of GNU grep. ok millert@ deraadt@ visa@ miod@
|
#
1.63 |
|
02-Dec-2019 |
jca |
With -R assume that "." was passed instead of printing a warning
Saner default behavior that matches GNU grep. Diff from miod@, support from espie@, ok visa@ millert@
|
Revision tags: OPENBSD_6_6_BASE
|
#
1.62 |
|
07-Oct-2019 |
tedu |
add --label to usage. thx jmc
|
#
1.61 |
|
07-Oct-2019 |
tedu |
two compat features to allow the zstdgrep script to work. add --label option to prefix the output instead of filename. allow using - to mean stdin. ok deraadt
|
#
1.60 |
|
18-Jul-2019 |
schwarze |
Delete documentation of --max-count, which is merely an alias of the documented -m. As a rule, we only document long options when users can't avoid them because they lack a short version.
As suggested by tedu@, as an exception, leave --context documented because -C is awkward in so far as it takes an optional option argument, which is fragile and error-prone and hence generally discouraged, including by POSIX.
Two years ago, kettenis@, deraadt@, and tedu@ all agreed that this is what should be done, and jmc@ was happy to accept the direction, but somehow everybody forgot to commit.
|
Revision tags: OPENBSD_6_5_BASE
|
#
1.59 |
|
31-Jan-2019 |
tedu |
convert fgetln to getline. this improves portability and sets a good better example for other code to follow. in the common case, grep uses mmap anyway (so no functional change). despite fgetln doing sneaky things with stdio internals, preliminary analysis by lauri suggests this may actually reduce the number of allocations. from Lauri Tirkkonen.
|
#
1.58 |
|
23-Jan-2019 |
tedu |
rework grep_open to be more careful about directories. cleaner, but should be no functional change. from Lauri Tirkkonen
|
Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
|
#
1.57 |
|
10-Dec-2017 |
jmc |
- add max-count to SYNOPSIS - list long options with short, where they have an equivalent - sync usage() - minor tweaks
|
#
1.56 |
|
09-Dec-2017 |
pirofti |
Add support for the non-standard grep -m extension.
grep -m num stops after a maximum of num matches are found. We support -m0 to match GNU behaviour, but we do not allow negative numbers.
Manpage help from jmc@, OK deraadt@.
|
Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
|
#
1.55 |
|
28-Nov-2015 |
gsoares |
fix exit status on pledge(2) error, where it should be >1
OK millert@ deraadt@
|
#
1.54 |
|
09-Oct-2015 |
deraadt |
Change all tame callers to namechange to pledge(2).
|
#
1.53 |
|
03-Oct-2015 |
deraadt |
grep only opens files read-only, reads via stdio or other methods, performs computation, and outputs result to stdout. (note: in the tame model, malloc is implicit because stdio needs it, and mmap is implicit since malloc needs it; libz is satisfied by this environment also).
this tame change consists of 1 line, setting "stdio rpath" before getopt. this protection is fairly strict. grep could be improved further by computing a wpathlist based on argv, keeping -R in mind. feel free to take a shot at it.
grep was an early target of capsicum also. know anyone running capsicum grep?
ok doug
|
#
1.52 |
|
27-Aug-2015 |
dlg |
use strtonum to parse the number of lines of context.
this provides better error messages.
ok deraadt@ guenther@
|
Revision tags: OPENBSD_5_8_BASE
|
#
1.51 |
|
30-Apr-2015 |
millert |
Add warning when user specifies -R but no files, like GNU grep. OK schwarze@ ian@
|
#
1.50 |
|
16-Mar-2015 |
millert |
Don't include limits.h or sys/limits.h since grep.h already does it for us.
|
Revision tags: OPENBSD_5_7_BASE
|
#
1.49 |
|
10-Jan-2015 |
tedu |
1. They're flags, not counters. Set to one instead of incrementing. 2. The G flag is useless and never checked. Remove it. ok millert
|
#
1.48 |
|
01-Dec-2014 |
deraadt |
use reallocarray()
|
#
1.47 |
|
26-Nov-2014 |
millert |
Prefer setvbuf() to setlinebuf() for portability; ok deraadt@
|
#
1.46 |
|
26-Nov-2014 |
millert |
Make option string/struct const (since it is...). I've had this in my tree for ages.
|
Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
|
#
1.45 |
|
29-Dec-2012 |
millert |
Fix exit status when there is an error reading a file. Reported by Jeramey Crawford, fix adapted from FreeBSD. OK guenther@
|
Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
|
#
1.44 |
|
08-Jul-2011 |
tedu |
add support for -o to only print the match. reminded this was useful by ajcoutot
|
#
1.43 |
|
04-Mar-2011 |
tedu |
add -H (opposite of -h) to always print name. ok deraadt millert
|
Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
|
#
1.42 |
|
02-Jul-2010 |
tedu |
Remove the "fast" grep code if SMALL. This has the side effect of breaking fgrep -w, but oh well. ok deraadt millert
|
#
1.41 |
|
20-Apr-2010 |
jacekm |
Fix "grep -e foo -w" crash. The problem lies in 'e' getopt clause calling add_pattern, which in turn assumes that the getopt phase has already finished.
OK otto@
|
#
1.40 |
|
05-Apr-2010 |
tedu |
remove some non-POSIX standard non-GNU defacto standard options, mostly relating to symlinks that you can get with find. And a bonus fts flag fix. With a small tweak by guenther. ok deraadt guenther jmc millert nicm
|
Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
|
#
1.39 |
|
02-Sep-2007 |
deraadt |
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
|
Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
|
#
1.38 |
|
13-Feb-2007 |
kili |
- Be explicit on command line checking, instead of relying on patterns, which may be NULL (e.g. -e ''). - let add_pattern() decide how to deal with empty patterns, don't do magic in read_patterns().
This unbreaks stuff like grep -e '', and makes grep -f <file> more POSIX compliant. Semantics for grep -f /dev/null (or any other empty file) may be questionable, but this case isn't specified by POSIX, and matching nothing at all seems to be sane.
Thanks to otto@, who mentioned potential problems related to the -x option with the first patch i sent.
ok jaredy@ (some time ago), otto@, millert@
|
#
1.37 |
|
02-Nov-2006 |
ray |
Check length before checking index of len - 1.
OK moritz@.
|
#
1.36 |
|
26-Sep-2006 |
jaredy |
Allow zero-length patterns with -x so
$ grep -x ""
matches empty lines as reported on misc@ by Martin Marusak <marusak@fhpv.unipo.sk>. Initial diff by otto@ with tweaks by me.
ok otto
|
Revision tags: OPENBSD_4_0_BASE
|
#
1.35 |
|
07-Mar-2006 |
otto |
Break patterns containing newlines into multiple patterns like POSIX says. Report by Ralf dot Wildenhues at gmx dot de; testing by jmc@ ok beck@ millert@
|
Revision tags: OPENBSD_3_9_BASE
|
#
1.34 |
|
09-Feb-2006 |
otto |
delint; remove redundant vars and functions; ok jaredy@
|
Revision tags: OPENBSD_3_8_BASE
|
#
1.33 |
|
03-Apr-2005 |
jaredy |
Make the processing of patterns collected from files specified by -f delayed so options that affect pattern-building (such as -w) can be applied evenly to all such patterns.
ok and help otto, ok millert
|
#
1.32 |
|
03-Apr-2005 |
otto |
Protect begin and end of word markers added to the pattern when using the -w option with parentheses, to avoid operators in the expressions binding to the markers. Compare [[:<:]]foo|bar[[:>:]] and [[:<:]](foo|bar)[[:>:]]. Problem spotted by aaron@; ok millert@ aaron@ jaredy@
|
Revision tags: OPENBSD_3_7_BASE
|
#
1.31 |
|
03-Oct-2004 |
otto |
Remove block based mmap optimization. There are newline problems (PR 3940, 3941) which can be fixed, but if a match starts at the end of a block and continues into the next block, no match will be found. Measurements by millert@ showed that the improvements of this optimization are non-measurable anyway. Diff from Alexander Taler.
ok millert@
|
#
1.30 |
|
28-Sep-2004 |
jmc |
various fixes to make this page a bit clearer and hopefully a bit more helpful;
this includes some ideas/fixes from otto and jared;
|
Revision tags: OPENBSD_3_6_BASE
|
#
1.29 |
|
05-Aug-2004 |
deraadt |
spacing
|
#
1.28 |
|
07-May-2004 |
millert |
Add a new past path for fgrep that is just a simplified version of fastcomp. This makes fgrep faster and fixes the -w flag w/ fgrep. Also remove free_patterns() since calling free right before exit is silly. Problem noticed by espie@
|
#
1.27 |
|
02-Apr-2004 |
otto |
Implement --line-buffered ok millert@ tedu@
|
Revision tags: OPENBSD_3_5_BASE
|
#
1.26 |
|
04-Feb-2004 |
millert |
Fix anchors (^ or $) in -w mode broken by the last commit's -w overhaul. With this change we pass the updated regress. Tested and OK by ho@
|
#
1.25 |
|
25-Jan-2004 |
millert |
Previously, in -w mode, for each match on a line grep would check to see if the match was on a word boundary. However, this missed lines where the first match was not on a word boundary but a subsequent match was. Problem originally spotted by miod@
We fix this by using the [[:<:]] and [[:>:]] character classes for the slow path and by checking the word boundaries in grep_search() for the fast path instead of doing the checks after running regexec() or grep_search().
With this change, grep passes the new regress tests 15 and 16. problem originally spotted by espie@.
|
#
1.24 |
|
11-Dec-2003 |
mcbride |
Sync usage() with SYNOPSIS in grep(1).
ok deraadt@ jmc@
|
Revision tags: OPENBSD_3_4_BASE
|
#
1.23 |
|
07-Sep-2003 |
millert |
Fix "grep -number" support for multi-digit numbers. At issue is the fact that optind refers to the *next* argument to be consumed by getopt(), not the current one. This means we have to keep track of when we are working with a new argv entry by hand. OK hugh@
|
#
1.22 |
|
16-Jul-2003 |
millert |
When reallocing pattern, use sizeof(*pattern) not sizeof(int). Fixes a problem on sparc64 where sizeof(int) != sizeof(pointer). Based on a patch from Brian Poole; tedu@ OK
|
#
1.21 |
|
14-Jul-2003 |
millert |
range-check numeric arguments (-num, -A num, -B num)
|
#
1.20 |
|
10-Jul-2003 |
millert |
grep should exit(2) on error, not exit(1) (1 means no matches found). deraadt@ OK
|
#
1.19 |
|
10-Jul-2003 |
deraadt |
knf
|
#
1.18 |
|
10-Jul-2003 |
millert |
Fix parsing of -NUMBER. We now do things a digit at a time and keep track of what the last char from getopt was as well as the previous value of optind so we know when a new number has started.
|
#
1.17 |
|
25-Jun-2003 |
millert |
o remove useless cast to int from gzread() call o maxPatternLen should be size_t since that's what it is compared against o remove useless casts of NULL to various pointer types
|
#
1.16 |
|
24-Jun-2003 |
tedu |
actually do fgrep. -G -F and -E are now mutally exclusive, and override the program name as expected. ok millert@
|
#
1.15 |
|
23-Jun-2003 |
tedu |
strncpy -> memcpy per deraadt suggestion. also add a note why we can't use strlcpy.
|
#
1.14 |
|
23-Jun-2003 |
tedu |
go back to using strncpy. for long patterns, strlcpy reads too much of a potentially nontermined src.
|
#
1.13 |
|
23-Jun-2003 |
tedu |
faster grep for simple patterns. derived from a patch by sean farley. this makes searching for constant strings much faster by avoiding regex. ok deraadt@
|
#
1.12 |
|
23-Jun-2003 |
deraadt |
minor tweaks
|
#
1.11 |
|
23-Jun-2003 |
tedu |
use strlcpy, not strncpy. ok deraadt@ millert@
|
#
1.10 |
|
23-Jun-2003 |
tedu |
spelling
|
#
1.9 |
|
23-Jun-2003 |
tedu |
better detetection/handling of binary files. make -a do the right thing, doc and implement -U, -I. add --help and --mmap for compatibility. some other minor fixes.
some from NetBSD. ok deraadt@
|
#
1.8 |
|
22-Jun-2003 |
tedu |
use __progname instead of progname. ok deraadt
|
#
1.7 |
|
22-Jun-2003 |
deraadt |
fix usage
|
#
1.6 |
|
22-Jun-2003 |
deraadt |
proper $OpenBSD$
|
#
1.5 |
|
22-Jun-2003 |
deraadt |
-DNOZ flag to be used by install media for removing z*grep support, if needed. (and knf)
|
#
1.4 |
|
22-Jun-2003 |
deraadt |
support z{e,f}grep
|
#
1.3 |
|
22-Jun-2003 |
deraadt |
freegrep 0.16
|
Revision tags: OPENBSD_3_3_BASE
|
#
1.2 |
|
16-Feb-2003 |
cloder |
Fix format string bug. I believe this grep is currently not used (in favor of the GNU version), but it gets fixed anyways. ok mickey@
|
Revision tags: OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE
|
#
1.1 |
|
21-Sep-2001 |
deraadt |
complete grep clone by harding@motd.ca; everything is there, but it is slow because libc regexp is slow. Anyone out there have the balls to sit down and optimize libc regexp?
|
#
1.62 |
|
07-Oct-2019 |
tedu |
add --label to usage. thx jmc
|
#
1.61 |
|
07-Oct-2019 |
tedu |
two compat features to allow the zstdgrep script to work. add --label option to prefix the output instead of filename. allow using - to mean stdin. ok deraadt
|
#
1.60 |
|
18-Jul-2019 |
schwarze |
Delete documentation of --max-count, which is merely an alias of the documented -m. As a rule, we only document long options when users can't avoid them because they lack a short version.
As suggested by tedu@, as an exception, leave --context documented because -C is awkward in so far as it takes an optional option argument, which is fragile and error-prone and hence generally discouraged, including by POSIX.
Two years ago, kettenis@, deraadt@, and tedu@ all agreed that this is what should be done, and jmc@ was happy to accept the direction, but somehow everybody forgot to commit.
|
Revision tags: OPENBSD_6_5_BASE
|
#
1.59 |
|
31-Jan-2019 |
tedu |
convert fgetln to getline. this improves portability and sets a good better example for other code to follow. in the common case, grep uses mmap anyway (so no functional change). despite fgetln doing sneaky things with stdio internals, preliminary analysis by lauri suggests this may actually reduce the number of allocations. from Lauri Tirkkonen.
|
#
1.58 |
|
23-Jan-2019 |
tedu |
rework grep_open to be more careful about directories. cleaner, but should be no functional change. from Lauri Tirkkonen
|
Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
|
#
1.57 |
|
10-Dec-2017 |
jmc |
- add max-count to SYNOPSIS - list long options with short, where they have an equivalent - sync usage() - minor tweaks
|
#
1.56 |
|
09-Dec-2017 |
pirofti |
Add support for the non-standard grep -m extension.
grep -m num stops after a maximum of num matches are found. We support -m0 to match GNU behaviour, but we do not allow negative numbers.
Manpage help from jmc@, OK deraadt@.
|
Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
|
#
1.55 |
|
28-Nov-2015 |
gsoares |
fix exit status on pledge(2) error, where it should be >1
OK millert@ deraadt@
|
#
1.54 |
|
09-Oct-2015 |
deraadt |
Change all tame callers to namechange to pledge(2).
|
#
1.53 |
|
03-Oct-2015 |
deraadt |
grep only opens files read-only, reads via stdio or other methods, performs computation, and outputs result to stdout. (note: in the tame model, malloc is implicit because stdio needs it, and mmap is implicit since malloc needs it; libz is satisfied by this environment also).
this tame change consists of 1 line, setting "stdio rpath" before getopt. this protection is fairly strict. grep could be improved further by computing a wpathlist based on argv, keeping -R in mind. feel free to take a shot at it.
grep was an early target of capsicum also. know anyone running capsicum grep?
ok doug
|
#
1.52 |
|
27-Aug-2015 |
dlg |
use strtonum to parse the number of lines of context.
this provides better error messages.
ok deraadt@ guenther@
|
Revision tags: OPENBSD_5_8_BASE
|
#
1.51 |
|
30-Apr-2015 |
millert |
Add warning when user specifies -R but no files, like GNU grep. OK schwarze@ ian@
|
#
1.50 |
|
16-Mar-2015 |
millert |
Don't include limits.h or sys/limits.h since grep.h already does it for us.
|
Revision tags: OPENBSD_5_7_BASE
|
#
1.49 |
|
10-Jan-2015 |
tedu |
1. They're flags, not counters. Set to one instead of incrementing. 2. The G flag is useless and never checked. Remove it. ok millert
|
#
1.48 |
|
01-Dec-2014 |
deraadt |
use reallocarray()
|
#
1.47 |
|
26-Nov-2014 |
millert |
Prefer setvbuf() to setlinebuf() for portability; ok deraadt@
|
#
1.46 |
|
26-Nov-2014 |
millert |
Make option string/struct const (since it is...). I've had this in my tree for ages.
|
Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
|
#
1.45 |
|
29-Dec-2012 |
millert |
Fix exit status when there is an error reading a file. Reported by Jeramey Crawford, fix adapted from FreeBSD. OK guenther@
|
Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
|
#
1.44 |
|
08-Jul-2011 |
tedu |
add support for -o to only print the match. reminded this was useful by ajcoutot
|
#
1.43 |
|
04-Mar-2011 |
tedu |
add -H (opposite of -h) to always print name. ok deraadt millert
|
Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
|
#
1.42 |
|
02-Jul-2010 |
tedu |
Remove the "fast" grep code if SMALL. This has the side effect of breaking fgrep -w, but oh well. ok deraadt millert
|
#
1.41 |
|
20-Apr-2010 |
jacekm |
Fix "grep -e foo -w" crash. The problem lies in 'e' getopt clause calling add_pattern, which in turn assumes that the getopt phase has already finished.
OK otto@
|
#
1.40 |
|
05-Apr-2010 |
tedu |
remove some non-POSIX standard non-GNU defacto standard options, mostly relating to symlinks that you can get with find. And a bonus fts flag fix. With a small tweak by guenther. ok deraadt guenther jmc millert nicm
|
Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
|
#
1.39 |
|
02-Sep-2007 |
deraadt |
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
|
Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
|
#
1.38 |
|
13-Feb-2007 |
kili |
- Be explicit on command line checking, instead of relying on patterns, which may be NULL (e.g. -e ''). - let add_pattern() decide how to deal with empty patterns, don't do magic in read_patterns().
This unbreaks stuff like grep -e '', and makes grep -f <file> more POSIX compliant. Semantics for grep -f /dev/null (or any other empty file) may be questionable, but this case isn't specified by POSIX, and matching nothing at all seems to be sane.
Thanks to otto@, who mentioned potential problems related to the -x option with the first patch i sent.
ok jaredy@ (some time ago), otto@, millert@
|
#
1.37 |
|
02-Nov-2006 |
ray |
Check length before checking index of len - 1.
OK moritz@.
|
#
1.36 |
|
26-Sep-2006 |
jaredy |
Allow zero-length patterns with -x so
$ grep -x ""
matches empty lines as reported on misc@ by Martin Marusak <marusak@fhpv.unipo.sk>. Initial diff by otto@ with tweaks by me.
ok otto
|
Revision tags: OPENBSD_4_0_BASE
|
#
1.35 |
|
07-Mar-2006 |
otto |
Break patterns containing newlines into multiple patterns like POSIX says. Report by Ralf dot Wildenhues at gmx dot de; testing by jmc@ ok beck@ millert@
|
Revision tags: OPENBSD_3_9_BASE
|
#
1.34 |
|
09-Feb-2006 |
otto |
delint; remove redundant vars and functions; ok jaredy@
|
Revision tags: OPENBSD_3_8_BASE
|
#
1.33 |
|
03-Apr-2005 |
jaredy |
Make the processing of patterns collected from files specified by -f delayed so options that affect pattern-building (such as -w) can be applied evenly to all such patterns.
ok and help otto, ok millert
|
#
1.32 |
|
03-Apr-2005 |
otto |
Protect begin and end of word markers added to the pattern when using the -w option with parentheses, to avoid operators in the expressions binding to the markers. Compare [[:<:]]foo|bar[[:>:]] and [[:<:]](foo|bar)[[:>:]]. Problem spotted by aaron@; ok millert@ aaron@ jaredy@
|
Revision tags: OPENBSD_3_7_BASE
|
#
1.31 |
|
03-Oct-2004 |
otto |
Remove block based mmap optimization. There are newline problems (PR 3940, 3941) which can be fixed, but if a match starts at the end of a block and continues into the next block, no match will be found. Measurements by millert@ showed that the improvements of this optimization are non-measurable anyway. Diff from Alexander Taler.
ok millert@
|
#
1.30 |
|
28-Sep-2004 |
jmc |
various fixes to make this page a bit clearer and hopefully a bit more helpful;
this includes some ideas/fixes from otto and jared;
|
Revision tags: OPENBSD_3_6_BASE
|
#
1.29 |
|
05-Aug-2004 |
deraadt |
spacing
|
#
1.28 |
|
07-May-2004 |
millert |
Add a new past path for fgrep that is just a simplified version of fastcomp. This makes fgrep faster and fixes the -w flag w/ fgrep. Also remove free_patterns() since calling free right before exit is silly. Problem noticed by espie@
|
#
1.27 |
|
02-Apr-2004 |
otto |
Implement --line-buffered ok millert@ tedu@
|
Revision tags: OPENBSD_3_5_BASE
|
#
1.26 |
|
04-Feb-2004 |
millert |
Fix anchors (^ or $) in -w mode broken by the last commit's -w overhaul. With this change we pass the updated regress. Tested and OK by ho@
|
#
1.25 |
|
25-Jan-2004 |
millert |
Previously, in -w mode, for each match on a line grep would check to see if the match was on a word boundary. However, this missed lines where the first match was not on a word boundary but a subsequent match was. Problem originally spotted by miod@
We fix this by using the [[:<:]] and [[:>:]] character classes for the slow path and by checking the word boundaries in grep_search() for the fast path instead of doing the checks after running regexec() or grep_search().
With this change, grep passes the new regress tests 15 and 16. problem originally spotted by espie@.
|
#
1.24 |
|
11-Dec-2003 |
mcbride |
Sync usage() with SYNOPSIS in grep(1).
ok deraadt@ jmc@
|
Revision tags: OPENBSD_3_4_BASE
|
#
1.23 |
|
07-Sep-2003 |
millert |
Fix "grep -number" support for multi-digit numbers. At issue is the fact that optind refers to the *next* argument to be consumed by getopt(), not the current one. This means we have to keep track of when we are working with a new argv entry by hand. OK hugh@
|
#
1.22 |
|
16-Jul-2003 |
millert |
When reallocing pattern, use sizeof(*pattern) not sizeof(int). Fixes a problem on sparc64 where sizeof(int) != sizeof(pointer). Based on a patch from Brian Poole; tedu@ OK
|
#
1.21 |
|
14-Jul-2003 |
millert |
range-check numeric arguments (-num, -A num, -B num)
|
#
1.20 |
|
10-Jul-2003 |
millert |
grep should exit(2) on error, not exit(1) (1 means no matches found). deraadt@ OK
|
#
1.19 |
|
10-Jul-2003 |
deraadt |
knf
|
#
1.18 |
|
10-Jul-2003 |
millert |
Fix parsing of -NUMBER. We now do things a digit at a time and keep track of what the last char from getopt was as well as the previous value of optind so we know when a new number has started.
|
#
1.17 |
|
25-Jun-2003 |
millert |
o remove useless cast to int from gzread() call o maxPatternLen should be size_t since that's what it is compared against o remove useless casts of NULL to various pointer types
|
#
1.16 |
|
24-Jun-2003 |
tedu |
actually do fgrep. -G -F and -E are now mutally exclusive, and override the program name as expected. ok millert@
|
#
1.15 |
|
23-Jun-2003 |
tedu |
strncpy -> memcpy per deraadt suggestion. also add a note why we can't use strlcpy.
|
#
1.14 |
|
23-Jun-2003 |
tedu |
go back to using strncpy. for long patterns, strlcpy reads too much of a potentially nontermined src.
|
#
1.13 |
|
23-Jun-2003 |
tedu |
faster grep for simple patterns. derived from a patch by sean farley. this makes searching for constant strings much faster by avoiding regex. ok deraadt@
|
#
1.12 |
|
23-Jun-2003 |
deraadt |
minor tweaks
|
#
1.11 |
|
23-Jun-2003 |
tedu |
use strlcpy, not strncpy. ok deraadt@ millert@
|
#
1.10 |
|
23-Jun-2003 |
tedu |
spelling
|
#
1.9 |
|
23-Jun-2003 |
tedu |
better detetection/handling of binary files. make -a do the right thing, doc and implement -U, -I. add --help and --mmap for compatibility. some other minor fixes.
some from NetBSD. ok deraadt@
|
#
1.8 |
|
22-Jun-2003 |
tedu |
use __progname instead of progname. ok deraadt
|
#
1.7 |
|
22-Jun-2003 |
deraadt |
fix usage
|
#
1.6 |
|
22-Jun-2003 |
deraadt |
proper $OpenBSD$
|
#
1.5 |
|
22-Jun-2003 |
deraadt |
-DNOZ flag to be used by install media for removing z*grep support, if needed. (and knf)
|
#
1.4 |
|
22-Jun-2003 |
deraadt |
support z{e,f}grep
|
#
1.3 |
|
22-Jun-2003 |
deraadt |
freegrep 0.16
|
Revision tags: OPENBSD_3_3_BASE
|
#
1.2 |
|
16-Feb-2003 |
cloder |
Fix format string bug. I believe this grep is currently not used (in favor of the GNU version), but it gets fixed anyways. ok mickey@
|
Revision tags: OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE
|
#
1.1 |
|
21-Sep-2001 |
deraadt |
complete grep clone by harding@motd.ca; everything is there, but it is slow because libc regexp is slow. Anyone out there have the balls to sit down and optimize libc regexp?
|
#
1.60 |
|
18-Jul-2019 |
schwarze |
Delete documentation of --max-count, which is merely an alias of the documented -m. As a rule, we only document long options when users can't avoid them because they lack a short version.
As suggested by tedu@, as an exception, leave --context documented because -C is awkward in so far as it takes an optional option argument, which is fragile and error-prone and hence generally discouraged, including by POSIX.
Two years ago, kettenis@, deraadt@, and tedu@ all agreed that this is what should be done, and jmc@ was happy to accept the direction, but somehow everybody forgot to commit.
|
Revision tags: OPENBSD_6_5_BASE
|
#
1.59 |
|
31-Jan-2019 |
tedu |
convert fgetln to getline. this improves portability and sets a good better example for other code to follow. in the common case, grep uses mmap anyway (so no functional change). despite fgetln doing sneaky things with stdio internals, preliminary analysis by lauri suggests this may actually reduce the number of allocations. from Lauri Tirkkonen.
|
#
1.58 |
|
23-Jan-2019 |
tedu |
rework grep_open to be more careful about directories. cleaner, but should be no functional change. from Lauri Tirkkonen
|
Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
|
#
1.57 |
|
10-Dec-2017 |
jmc |
- add max-count to SYNOPSIS - list long options with short, where they have an equivalent - sync usage() - minor tweaks
|
#
1.56 |
|
09-Dec-2017 |
pirofti |
Add support for the non-standard grep -m extension.
grep -m num stops after a maximum of num matches are found. We support -m0 to match GNU behaviour, but we do not allow negative numbers.
Manpage help from jmc@, OK deraadt@.
|
Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
|
#
1.55 |
|
28-Nov-2015 |
gsoares |
fix exit status on pledge(2) error, where it should be >1
OK millert@ deraadt@
|
#
1.54 |
|
09-Oct-2015 |
deraadt |
Change all tame callers to namechange to pledge(2).
|
#
1.53 |
|
03-Oct-2015 |
deraadt |
grep only opens files read-only, reads via stdio or other methods, performs computation, and outputs result to stdout. (note: in the tame model, malloc is implicit because stdio needs it, and mmap is implicit since malloc needs it; libz is satisfied by this environment also).
this tame change consists of 1 line, setting "stdio rpath" before getopt. this protection is fairly strict. grep could be improved further by computing a wpathlist based on argv, keeping -R in mind. feel free to take a shot at it.
grep was an early target of capsicum also. know anyone running capsicum grep?
ok doug
|
#
1.52 |
|
27-Aug-2015 |
dlg |
use strtonum to parse the number of lines of context.
this provides better error messages.
ok deraadt@ guenther@
|
Revision tags: OPENBSD_5_8_BASE
|
#
1.51 |
|
30-Apr-2015 |
millert |
Add warning when user specifies -R but no files, like GNU grep. OK schwarze@ ian@
|
#
1.50 |
|
16-Mar-2015 |
millert |
Don't include limits.h or sys/limits.h since grep.h already does it for us.
|
Revision tags: OPENBSD_5_7_BASE
|
#
1.49 |
|
10-Jan-2015 |
tedu |
1. They're flags, not counters. Set to one instead of incrementing. 2. The G flag is useless and never checked. Remove it. ok millert
|
#
1.48 |
|
01-Dec-2014 |
deraadt |
use reallocarray()
|
#
1.47 |
|
26-Nov-2014 |
millert |
Prefer setvbuf() to setlinebuf() for portability; ok deraadt@
|
#
1.46 |
|
26-Nov-2014 |
millert |
Make option string/struct const (since it is...). I've had this in my tree for ages.
|
Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
|
#
1.45 |
|
29-Dec-2012 |
millert |
Fix exit status when there is an error reading a file. Reported by Jeramey Crawford, fix adapted from FreeBSD. OK guenther@
|
Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
|
#
1.44 |
|
08-Jul-2011 |
tedu |
add support for -o to only print the match. reminded this was useful by ajcoutot
|
#
1.43 |
|
04-Mar-2011 |
tedu |
add -H (opposite of -h) to always print name. ok deraadt millert
|
Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
|
#
1.42 |
|
02-Jul-2010 |
tedu |
Remove the "fast" grep code if SMALL. This has the side effect of breaking fgrep -w, but oh well. ok deraadt millert
|
#
1.41 |
|
20-Apr-2010 |
jacekm |
Fix "grep -e foo -w" crash. The problem lies in 'e' getopt clause calling add_pattern, which in turn assumes that the getopt phase has already finished.
OK otto@
|
#
1.40 |
|
05-Apr-2010 |
tedu |
remove some non-POSIX standard non-GNU defacto standard options, mostly relating to symlinks that you can get with find. And a bonus fts flag fix. With a small tweak by guenther. ok deraadt guenther jmc millert nicm
|
Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
|
#
1.39 |
|
02-Sep-2007 |
deraadt |
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
|
Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
|
#
1.38 |
|
13-Feb-2007 |
kili |
- Be explicit on command line checking, instead of relying on patterns, which may be NULL (e.g. -e ''). - let add_pattern() decide how to deal with empty patterns, don't do magic in read_patterns().
This unbreaks stuff like grep -e '', and makes grep -f <file> more POSIX compliant. Semantics for grep -f /dev/null (or any other empty file) may be questionable, but this case isn't specified by POSIX, and matching nothing at all seems to be sane.
Thanks to otto@, who mentioned potential problems related to the -x option with the first patch i sent.
ok jaredy@ (some time ago), otto@, millert@
|
#
1.37 |
|
02-Nov-2006 |
ray |
Check length before checking index of len - 1.
OK moritz@.
|
#
1.36 |
|
26-Sep-2006 |
jaredy |
Allow zero-length patterns with -x so
$ grep -x ""
matches empty lines as reported on misc@ by Martin Marusak <marusak@fhpv.unipo.sk>. Initial diff by otto@ with tweaks by me.
ok otto
|
Revision tags: OPENBSD_4_0_BASE
|
#
1.35 |
|
07-Mar-2006 |
otto |
Break patterns containing newlines into multiple patterns like POSIX says. Report by Ralf dot Wildenhues at gmx dot de; testing by jmc@ ok beck@ millert@
|
Revision tags: OPENBSD_3_9_BASE
|
#
1.34 |
|
09-Feb-2006 |
otto |
delint; remove redundant vars and functions; ok jaredy@
|
Revision tags: OPENBSD_3_8_BASE
|
#
1.33 |
|
03-Apr-2005 |
jaredy |
Make the processing of patterns collected from files specified by -f delayed so options that affect pattern-building (such as -w) can be applied evenly to all such patterns.
ok and help otto, ok millert
|
#
1.32 |
|
03-Apr-2005 |
otto |
Protect begin and end of word markers added to the pattern when using the -w option with parentheses, to avoid operators in the expressions binding to the markers. Compare [[:<:]]foo|bar[[:>:]] and [[:<:]](foo|bar)[[:>:]]. Problem spotted by aaron@; ok millert@ aaron@ jaredy@
|
Revision tags: OPENBSD_3_7_BASE
|
#
1.31 |
|
03-Oct-2004 |
otto |
Remove block based mmap optimization. There are newline problems (PR 3940, 3941) which can be fixed, but if a match starts at the end of a block and continues into the next block, no match will be found. Measurements by millert@ showed that the improvements of this optimization are non-measurable anyway. Diff from Alexander Taler.
ok millert@
|
#
1.30 |
|
28-Sep-2004 |
jmc |
various fixes to make this page a bit clearer and hopefully a bit more helpful;
this includes some ideas/fixes from otto and jared;
|
Revision tags: OPENBSD_3_6_BASE
|
#
1.29 |
|
05-Aug-2004 |
deraadt |
spacing
|
#
1.28 |
|
07-May-2004 |
millert |
Add a new past path for fgrep that is just a simplified version of fastcomp. This makes fgrep faster and fixes the -w flag w/ fgrep. Also remove free_patterns() since calling free right before exit is silly. Problem noticed by espie@
|
#
1.27 |
|
02-Apr-2004 |
otto |
Implement --line-buffered ok millert@ tedu@
|
Revision tags: OPENBSD_3_5_BASE
|
#
1.26 |
|
04-Feb-2004 |
millert |
Fix anchors (^ or $) in -w mode broken by the last commit's -w overhaul. With this change we pass the updated regress. Tested and OK by ho@
|
#
1.25 |
|
25-Jan-2004 |
millert |
Previously, in -w mode, for each match on a line grep would check to see if the match was on a word boundary. However, this missed lines where the first match was not on a word boundary but a subsequent match was. Problem originally spotted by miod@
We fix this by using the [[:<:]] and [[:>:]] character classes for the slow path and by checking the word boundaries in grep_search() for the fast path instead of doing the checks after running regexec() or grep_search().
With this change, grep passes the new regress tests 15 and 16. problem originally spotted by espie@.
|
#
1.24 |
|
11-Dec-2003 |
mcbride |
Sync usage() with SYNOPSIS in grep(1).
ok deraadt@ jmc@
|
Revision tags: OPENBSD_3_4_BASE
|
#
1.23 |
|
07-Sep-2003 |
millert |
Fix "grep -number" support for multi-digit numbers. At issue is the fact that optind refers to the *next* argument to be consumed by getopt(), not the current one. This means we have to keep track of when we are working with a new argv entry by hand. OK hugh@
|
#
1.22 |
|
16-Jul-2003 |
millert |
When reallocing pattern, use sizeof(*pattern) not sizeof(int). Fixes a problem on sparc64 where sizeof(int) != sizeof(pointer). Based on a patch from Brian Poole; tedu@ OK
|
#
1.21 |
|
14-Jul-2003 |
millert |
range-check numeric arguments (-num, -A num, -B num)
|
#
1.20 |
|
10-Jul-2003 |
millert |
grep should exit(2) on error, not exit(1) (1 means no matches found). deraadt@ OK
|
#
1.19 |
|
10-Jul-2003 |
deraadt |
knf
|
#
1.18 |
|
10-Jul-2003 |
millert |
Fix parsing of -NUMBER. We now do things a digit at a time and keep track of what the last char from getopt was as well as the previous value of optind so we know when a new number has started.
|
#
1.17 |
|
25-Jun-2003 |
millert |
o remove useless cast to int from gzread() call o maxPatternLen should be size_t since that's what it is compared against o remove useless casts of NULL to various pointer types
|
#
1.16 |
|
24-Jun-2003 |
tedu |
actually do fgrep. -G -F and -E are now mutally exclusive, and override the program name as expected. ok millert@
|
#
1.15 |
|
23-Jun-2003 |
tedu |
strncpy -> memcpy per deraadt suggestion. also add a note why we can't use strlcpy.
|
#
1.14 |
|
23-Jun-2003 |
tedu |
go back to using strncpy. for long patterns, strlcpy reads too much of a potentially nontermined src.
|
#
1.13 |
|
23-Jun-2003 |
tedu |
faster grep for simple patterns. derived from a patch by sean farley. this makes searching for constant strings much faster by avoiding regex. ok deraadt@
|
#
1.12 |
|
23-Jun-2003 |
deraadt |
minor tweaks
|
#
1.11 |
|
23-Jun-2003 |
tedu |
use strlcpy, not strncpy. ok deraadt@ millert@
|
#
1.10 |
|
23-Jun-2003 |
tedu |
spelling
|
#
1.9 |
|
23-Jun-2003 |
tedu |
better detetection/handling of binary files. make -a do the right thing, doc and implement -U, -I. add --help and --mmap for compatibility. some other minor fixes.
some from NetBSD. ok deraadt@
|
#
1.8 |
|
22-Jun-2003 |
tedu |
use __progname instead of progname. ok deraadt
|
#
1.7 |
|
22-Jun-2003 |
deraadt |
fix usage
|
#
1.6 |
|
22-Jun-2003 |
deraadt |
proper $OpenBSD$
|
#
1.5 |
|
22-Jun-2003 |
deraadt |
-DNOZ flag to be used by install media for removing z*grep support, if needed. (and knf)
|
#
1.4 |
|
22-Jun-2003 |
deraadt |
support z{e,f}grep
|
#
1.3 |
|
22-Jun-2003 |
deraadt |
freegrep 0.16
|
Revision tags: OPENBSD_3_3_BASE
|
#
1.2 |
|
16-Feb-2003 |
cloder |
Fix format string bug. I believe this grep is currently not used (in favor of the GNU version), but it gets fixed anyways. ok mickey@
|
Revision tags: OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE
|
#
1.1 |
|
21-Sep-2001 |
deraadt |
complete grep clone by harding@motd.ca; everything is there, but it is slow because libc regexp is slow. Anyone out there have the balls to sit down and optimize libc regexp?
|
#
1.59 |
|
31-Jan-2019 |
tedu |
convert fgetln to getline. this improves portability and sets a good better example for other code to follow. in the common case, grep uses mmap anyway (so no functional change). despite fgetln doing sneaky things with stdio internals, preliminary analysis by lauri suggests this may actually reduce the number of allocations. from Lauri Tirkkonen.
|
#
1.58 |
|
23-Jan-2019 |
tedu |
rework grep_open to be more careful about directories. cleaner, but should be no functional change. from Lauri Tirkkonen
|
Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
|
#
1.57 |
|
10-Dec-2017 |
jmc |
- add max-count to SYNOPSIS - list long options with short, where they have an equivalent - sync usage() - minor tweaks
|
#
1.56 |
|
09-Dec-2017 |
pirofti |
Add support for the non-standard grep -m extension.
grep -m num stops after a maximum of num matches are found. We support -m0 to match GNU behaviour, but we do not allow negative numbers.
Manpage help from jmc@, OK deraadt@.
|
Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
|
#
1.55 |
|
28-Nov-2015 |
gsoares |
fix exit status on pledge(2) error, where it should be >1
OK millert@ deraadt@
|
#
1.54 |
|
09-Oct-2015 |
deraadt |
Change all tame callers to namechange to pledge(2).
|
#
1.53 |
|
03-Oct-2015 |
deraadt |
grep only opens files read-only, reads via stdio or other methods, performs computation, and outputs result to stdout. (note: in the tame model, malloc is implicit because stdio needs it, and mmap is implicit since malloc needs it; libz is satisfied by this environment also).
this tame change consists of 1 line, setting "stdio rpath" before getopt. this protection is fairly strict. grep could be improved further by computing a wpathlist based on argv, keeping -R in mind. feel free to take a shot at it.
grep was an early target of capsicum also. know anyone running capsicum grep?
ok doug
|
#
1.52 |
|
27-Aug-2015 |
dlg |
use strtonum to parse the number of lines of context.
this provides better error messages.
ok deraadt@ guenther@
|
Revision tags: OPENBSD_5_8_BASE
|
#
1.51 |
|
30-Apr-2015 |
millert |
Add warning when user specifies -R but no files, like GNU grep. OK schwarze@ ian@
|
#
1.50 |
|
16-Mar-2015 |
millert |
Don't include limits.h or sys/limits.h since grep.h already does it for us.
|
Revision tags: OPENBSD_5_7_BASE
|
#
1.49 |
|
10-Jan-2015 |
tedu |
1. They're flags, not counters. Set to one instead of incrementing. 2. The G flag is useless and never checked. Remove it. ok millert
|
#
1.48 |
|
01-Dec-2014 |
deraadt |
use reallocarray()
|
#
1.47 |
|
26-Nov-2014 |
millert |
Prefer setvbuf() to setlinebuf() for portability; ok deraadt@
|
#
1.46 |
|
26-Nov-2014 |
millert |
Make option string/struct const (since it is...). I've had this in my tree for ages.
|
Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
|
#
1.45 |
|
29-Dec-2012 |
millert |
Fix exit status when there is an error reading a file. Reported by Jeramey Crawford, fix adapted from FreeBSD. OK guenther@
|
Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
|
#
1.44 |
|
08-Jul-2011 |
tedu |
add support for -o to only print the match. reminded this was useful by ajcoutot
|
#
1.43 |
|
04-Mar-2011 |
tedu |
add -H (opposite of -h) to always print name. ok deraadt millert
|
Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
|
#
1.42 |
|
02-Jul-2010 |
tedu |
Remove the "fast" grep code if SMALL. This has the side effect of breaking fgrep -w, but oh well. ok deraadt millert
|
#
1.41 |
|
20-Apr-2010 |
jacekm |
Fix "grep -e foo -w" crash. The problem lies in 'e' getopt clause calling add_pattern, which in turn assumes that the getopt phase has already finished.
OK otto@
|
#
1.40 |
|
05-Apr-2010 |
tedu |
remove some non-POSIX standard non-GNU defacto standard options, mostly relating to symlinks that you can get with find. And a bonus fts flag fix. With a small tweak by guenther. ok deraadt guenther jmc millert nicm
|
Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
|
#
1.39 |
|
02-Sep-2007 |
deraadt |
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
|
Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
|
#
1.38 |
|
13-Feb-2007 |
kili |
- Be explicit on command line checking, instead of relying on patterns, which may be NULL (e.g. -e ''). - let add_pattern() decide how to deal with empty patterns, don't do magic in read_patterns().
This unbreaks stuff like grep -e '', and makes grep -f <file> more POSIX compliant. Semantics for grep -f /dev/null (or any other empty file) may be questionable, but this case isn't specified by POSIX, and matching nothing at all seems to be sane.
Thanks to otto@, who mentioned potential problems related to the -x option with the first patch i sent.
ok jaredy@ (some time ago), otto@, millert@
|
#
1.37 |
|
02-Nov-2006 |
ray |
Check length before checking index of len - 1.
OK moritz@.
|
#
1.36 |
|
26-Sep-2006 |
jaredy |
Allow zero-length patterns with -x so
$ grep -x ""
matches empty lines as reported on misc@ by Martin Marusak <marusak@fhpv.unipo.sk>. Initial diff by otto@ with tweaks by me.
ok otto
|
Revision tags: OPENBSD_4_0_BASE
|
#
1.35 |
|
07-Mar-2006 |
otto |
Break patterns containing newlines into multiple patterns like POSIX says. Report by Ralf dot Wildenhues at gmx dot de; testing by jmc@ ok beck@ millert@
|
Revision tags: OPENBSD_3_9_BASE
|
#
1.34 |
|
09-Feb-2006 |
otto |
delint; remove redundant vars and functions; ok jaredy@
|
Revision tags: OPENBSD_3_8_BASE
|
#
1.33 |
|
03-Apr-2005 |
jaredy |
Make the processing of patterns collected from files specified by -f delayed so options that affect pattern-building (such as -w) can be applied evenly to all such patterns.
ok and help otto, ok millert
|
#
1.32 |
|
03-Apr-2005 |
otto |
Protect begin and end of word markers added to the pattern when using the -w option with parentheses, to avoid operators in the expressions binding to the markers. Compare [[:<:]]foo|bar[[:>:]] and [[:<:]](foo|bar)[[:>:]]. Problem spotted by aaron@; ok millert@ aaron@ jaredy@
|
Revision tags: OPENBSD_3_7_BASE
|
#
1.31 |
|
03-Oct-2004 |
otto |
Remove block based mmap optimization. There are newline problems (PR 3940, 3941) which can be fixed, but if a match starts at the end of a block and continues into the next block, no match will be found. Measurements by millert@ showed that the improvements of this optimization are non-measurable anyway. Diff from Alexander Taler.
ok millert@
|
#
1.30 |
|
28-Sep-2004 |
jmc |
various fixes to make this page a bit clearer and hopefully a bit more helpful;
this includes some ideas/fixes from otto and jared;
|
Revision tags: OPENBSD_3_6_BASE
|
#
1.29 |
|
05-Aug-2004 |
deraadt |
spacing
|
#
1.28 |
|
07-May-2004 |
millert |
Add a new past path for fgrep that is just a simplified version of fastcomp. This makes fgrep faster and fixes the -w flag w/ fgrep. Also remove free_patterns() since calling free right before exit is silly. Problem noticed by espie@
|
#
1.27 |
|
02-Apr-2004 |
otto |
Implement --line-buffered ok millert@ tedu@
|
Revision tags: OPENBSD_3_5_BASE
|
#
1.26 |
|
04-Feb-2004 |
millert |
Fix anchors (^ or $) in -w mode broken by the last commit's -w overhaul. With this change we pass the updated regress. Tested and OK by ho@
|
#
1.25 |
|
25-Jan-2004 |
millert |
Previously, in -w mode, for each match on a line grep would check to see if the match was on a word boundary. However, this missed lines where the first match was not on a word boundary but a subsequent match was. Problem originally spotted by miod@
We fix this by using the [[:<:]] and [[:>:]] character classes for the slow path and by checking the word boundaries in grep_search() for the fast path instead of doing the checks after running regexec() or grep_search().
With this change, grep passes the new regress tests 15 and 16. problem originally spotted by espie@.
|
#
1.24 |
|
11-Dec-2003 |
mcbride |
Sync usage() with SYNOPSIS in grep(1).
ok deraadt@ jmc@
|
Revision tags: OPENBSD_3_4_BASE
|
#
1.23 |
|
07-Sep-2003 |
millert |
Fix "grep -number" support for multi-digit numbers. At issue is the fact that optind refers to the *next* argument to be consumed by getopt(), not the current one. This means we have to keep track of when we are working with a new argv entry by hand. OK hugh@
|
#
1.22 |
|
16-Jul-2003 |
millert |
When reallocing pattern, use sizeof(*pattern) not sizeof(int). Fixes a problem on sparc64 where sizeof(int) != sizeof(pointer). Based on a patch from Brian Poole; tedu@ OK
|
#
1.21 |
|
14-Jul-2003 |
millert |
range-check numeric arguments (-num, -A num, -B num)
|
#
1.20 |
|
10-Jul-2003 |
millert |
grep should exit(2) on error, not exit(1) (1 means no matches found). deraadt@ OK
|
#
1.19 |
|
10-Jul-2003 |
deraadt |
knf
|
#
1.18 |
|
10-Jul-2003 |
millert |
Fix parsing of -NUMBER. We now do things a digit at a time and keep track of what the last char from getopt was as well as the previous value of optind so we know when a new number has started.
|
#
1.17 |
|
25-Jun-2003 |
millert |
o remove useless cast to int from gzread() call o maxPatternLen should be size_t since that's what it is compared against o remove useless casts of NULL to various pointer types
|
#
1.16 |
|
24-Jun-2003 |
tedu |
actually do fgrep. -G -F and -E are now mutally exclusive, and override the program name as expected. ok millert@
|
#
1.15 |
|
23-Jun-2003 |
tedu |
strncpy -> memcpy per deraadt suggestion. also add a note why we can't use strlcpy.
|
#
1.14 |
|
23-Jun-2003 |
tedu |
go back to using strncpy. for long patterns, strlcpy reads too much of a potentially nontermined src.
|
#
1.13 |
|
23-Jun-2003 |
tedu |
faster grep for simple patterns. derived from a patch by sean farley. this makes searching for constant strings much faster by avoiding regex. ok deraadt@
|
#
1.12 |
|
23-Jun-2003 |
deraadt |
minor tweaks
|
#
1.11 |
|
23-Jun-2003 |
tedu |
use strlcpy, not strncpy. ok deraadt@ millert@
|
#
1.10 |
|
23-Jun-2003 |
tedu |
spelling
|
#
1.9 |
|
23-Jun-2003 |
tedu |
better detetection/handling of binary files. make -a do the right thing, doc and implement -U, -I. add --help and --mmap for compatibility. some other minor fixes.
some from NetBSD. ok deraadt@
|
#
1.8 |
|
22-Jun-2003 |
tedu |
use __progname instead of progname. ok deraadt
|
#
1.7 |
|
22-Jun-2003 |
deraadt |
fix usage
|
#
1.6 |
|
22-Jun-2003 |
deraadt |
proper $OpenBSD$
|
#
1.5 |
|
22-Jun-2003 |
deraadt |
-DNOZ flag to be used by install media for removing z*grep support, if needed. (and knf)
|
#
1.4 |
|
22-Jun-2003 |
deraadt |
support z{e,f}grep
|
#
1.3 |
|
22-Jun-2003 |
deraadt |
freegrep 0.16
|
Revision tags: OPENBSD_3_3_BASE
|
#
1.2 |
|
16-Feb-2003 |
cloder |
Fix format string bug. I believe this grep is currently not used (in favor of the GNU version), but it gets fixed anyways. ok mickey@
|
Revision tags: OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE
|
#
1.1 |
|
21-Sep-2001 |
deraadt |
complete grep clone by harding@motd.ca; everything is there, but it is slow because libc regexp is slow. Anyone out there have the balls to sit down and optimize libc regexp?
|
#
1.58 |
|
23-Jan-2019 |
tedu |
rework grep_open to be more careful about directories. cleaner, but should be no functional change. from Lauri Tirkkonen
|
Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE
|
#
1.57 |
|
10-Dec-2017 |
jmc |
- add max-count to SYNOPSIS - list long options with short, where they have an equivalent - sync usage() - minor tweaks
|
#
1.56 |
|
09-Dec-2017 |
pirofti |
Add support for the non-standard grep -m extension.
grep -m num stops after a maximum of num matches are found. We support -m0 to match GNU behaviour, but we do not allow negative numbers.
Manpage help from jmc@, OK deraadt@.
|
Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
|
#
1.55 |
|
28-Nov-2015 |
gsoares |
fix exit status on pledge(2) error, where it should be >1
OK millert@ deraadt@
|
#
1.54 |
|
09-Oct-2015 |
deraadt |
Change all tame callers to namechange to pledge(2).
|
#
1.53 |
|
03-Oct-2015 |
deraadt |
grep only opens files read-only, reads via stdio or other methods, performs computation, and outputs result to stdout. (note: in the tame model, malloc is implicit because stdio needs it, and mmap is implicit since malloc needs it; libz is satisfied by this environment also).
this tame change consists of 1 line, setting "stdio rpath" before getopt. this protection is fairly strict. grep could be improved further by computing a wpathlist based on argv, keeping -R in mind. feel free to take a shot at it.
grep was an early target of capsicum also. know anyone running capsicum grep?
ok doug
|
#
1.52 |
|
27-Aug-2015 |
dlg |
use strtonum to parse the number of lines of context.
this provides better error messages.
ok deraadt@ guenther@
|
Revision tags: OPENBSD_5_8_BASE
|
#
1.51 |
|
30-Apr-2015 |
millert |
Add warning when user specifies -R but no files, like GNU grep. OK schwarze@ ian@
|
#
1.50 |
|
16-Mar-2015 |
millert |
Don't include limits.h or sys/limits.h since grep.h already does it for us.
|
Revision tags: OPENBSD_5_7_BASE
|
#
1.49 |
|
10-Jan-2015 |
tedu |
1. They're flags, not counters. Set to one instead of incrementing. 2. The G flag is useless and never checked. Remove it. ok millert
|
#
1.48 |
|
01-Dec-2014 |
deraadt |
use reallocarray()
|
#
1.47 |
|
26-Nov-2014 |
millert |
Prefer setvbuf() to setlinebuf() for portability; ok deraadt@
|
#
1.46 |
|
26-Nov-2014 |
millert |
Make option string/struct const (since it is...). I've had this in my tree for ages.
|
Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
|
#
1.45 |
|
29-Dec-2012 |
millert |
Fix exit status when there is an error reading a file. Reported by Jeramey Crawford, fix adapted from FreeBSD. OK guenther@
|
Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
|
#
1.44 |
|
08-Jul-2011 |
tedu |
add support for -o to only print the match. reminded this was useful by ajcoutot
|
#
1.43 |
|
04-Mar-2011 |
tedu |
add -H (opposite of -h) to always print name. ok deraadt millert
|
Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
|
#
1.42 |
|
02-Jul-2010 |
tedu |
Remove the "fast" grep code if SMALL. This has the side effect of breaking fgrep -w, but oh well. ok deraadt millert
|
#
1.41 |
|
20-Apr-2010 |
jacekm |
Fix "grep -e foo -w" crash. The problem lies in 'e' getopt clause calling add_pattern, which in turn assumes that the getopt phase has already finished.
OK otto@
|
#
1.40 |
|
05-Apr-2010 |
tedu |
remove some non-POSIX standard non-GNU defacto standard options, mostly relating to symlinks that you can get with find. And a bonus fts flag fix. With a small tweak by guenther. ok deraadt guenther jmc millert nicm
|
Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
|
#
1.39 |
|
02-Sep-2007 |
deraadt |
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
|
Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
|
#
1.38 |
|
13-Feb-2007 |
kili |
- Be explicit on command line checking, instead of relying on patterns, which may be NULL (e.g. -e ''). - let add_pattern() decide how to deal with empty patterns, don't do magic in read_patterns().
This unbreaks stuff like grep -e '', and makes grep -f <file> more POSIX compliant. Semantics for grep -f /dev/null (or any other empty file) may be questionable, but this case isn't specified by POSIX, and matching nothing at all seems to be sane.
Thanks to otto@, who mentioned potential problems related to the -x option with the first patch i sent.
ok jaredy@ (some time ago), otto@, millert@
|
#
1.37 |
|
02-Nov-2006 |
ray |
Check length before checking index of len - 1.
OK moritz@.
|
#
1.36 |
|
26-Sep-2006 |
jaredy |
Allow zero-length patterns with -x so
$ grep -x ""
matches empty lines as reported on misc@ by Martin Marusak <marusak@fhpv.unipo.sk>. Initial diff by otto@ with tweaks by me.
ok otto
|
Revision tags: OPENBSD_4_0_BASE
|
#
1.35 |
|
07-Mar-2006 |
otto |
Break patterns containing newlines into multiple patterns like POSIX says. Report by Ralf dot Wildenhues at gmx dot de; testing by jmc@ ok beck@ millert@
|
Revision tags: OPENBSD_3_9_BASE
|
#
1.34 |
|
09-Feb-2006 |
otto |
delint; remove redundant vars and functions; ok jaredy@
|
Revision tags: OPENBSD_3_8_BASE
|
#
1.33 |
|
03-Apr-2005 |
jaredy |
Make the processing of patterns collected from files specified by -f delayed so options that affect pattern-building (such as -w) can be applied evenly to all such patterns.
ok and help otto, ok millert
|
#
1.32 |
|
03-Apr-2005 |
otto |
Protect begin and end of word markers added to the pattern when using the -w option with parentheses, to avoid operators in the expressions binding to the markers. Compare [[:<:]]foo|bar[[:>:]] and [[:<:]](foo|bar)[[:>:]]. Problem spotted by aaron@; ok millert@ aaron@ jaredy@
|
Revision tags: OPENBSD_3_7_BASE
|
#
1.31 |
|
03-Oct-2004 |
otto |
Remove block based mmap optimization. There are newline problems (PR 3940, 3941) which can be fixed, but if a match starts at the end of a block and continues into the next block, no match will be found. Measurements by millert@ showed that the improvements of this optimization are non-measurable anyway. Diff from Alexander Taler.
ok millert@
|
#
1.30 |
|
28-Sep-2004 |
jmc |
various fixes to make this page a bit clearer and hopefully a bit more helpful;
this includes some ideas/fixes from otto and jared;
|
Revision tags: OPENBSD_3_6_BASE
|
#
1.29 |
|
05-Aug-2004 |
deraadt |
spacing
|
#
1.28 |
|
07-May-2004 |
millert |
Add a new past path for fgrep that is just a simplified version of fastcomp. This makes fgrep faster and fixes the -w flag w/ fgrep. Also remove free_patterns() since calling free right before exit is silly. Problem noticed by espie@
|
#
1.27 |
|
02-Apr-2004 |
otto |
Implement --line-buffered ok millert@ tedu@
|
Revision tags: OPENBSD_3_5_BASE
|
#
1.26 |
|
04-Feb-2004 |
millert |
Fix anchors (^ or $) in -w mode broken by the last commit's -w overhaul. With this change we pass the updated regress. Tested and OK by ho@
|
#
1.25 |
|
25-Jan-2004 |
millert |
Previously, in -w mode, for each match on a line grep would check to see if the match was on a word boundary. However, this missed lines where the first match was not on a word boundary but a subsequent match was. Problem originally spotted by miod@
We fix this by using the [[:<:]] and [[:>:]] character classes for the slow path and by checking the word boundaries in grep_search() for the fast path instead of doing the checks after running regexec() or grep_search().
With this change, grep passes the new regress tests 15 and 16. problem originally spotted by espie@.
|
#
1.24 |
|
11-Dec-2003 |
mcbride |
Sync usage() with SYNOPSIS in grep(1).
ok deraadt@ jmc@
|
Revision tags: OPENBSD_3_4_BASE
|
#
1.23 |
|
07-Sep-2003 |
millert |
Fix "grep -number" support for multi-digit numbers. At issue is the fact that optind refers to the *next* argument to be consumed by getopt(), not the current one. This means we have to keep track of when we are working with a new argv entry by hand. OK hugh@
|
#
1.22 |
|
16-Jul-2003 |
millert |
When reallocing pattern, use sizeof(*pattern) not sizeof(int). Fixes a problem on sparc64 where sizeof(int) != sizeof(pointer). Based on a patch from Brian Poole; tedu@ OK
|
#
1.21 |
|
14-Jul-2003 |
millert |
range-check numeric arguments (-num, -A num, -B num)
|
#
1.20 |
|
10-Jul-2003 |
millert |
grep should exit(2) on error, not exit(1) (1 means no matches found). deraadt@ OK
|
#
1.19 |
|
10-Jul-2003 |
deraadt |
knf
|
#
1.18 |
|
10-Jul-2003 |
millert |
Fix parsing of -NUMBER. We now do things a digit at a time and keep track of what the last char from getopt was as well as the previous value of optind so we know when a new number has started.
|
#
1.17 |
|
25-Jun-2003 |
millert |
o remove useless cast to int from gzread() call o maxPatternLen should be size_t since that's what it is compared against o remove useless casts of NULL to various pointer types
|
#
1.16 |
|
24-Jun-2003 |
tedu |
actually do fgrep. -G -F and -E are now mutally exclusive, and override the program name as expected. ok millert@
|
#
1.15 |
|
23-Jun-2003 |
tedu |
strncpy -> memcpy per deraadt suggestion. also add a note why we can't use strlcpy.
|
#
1.14 |
|
23-Jun-2003 |
tedu |
go back to using strncpy. for long patterns, strlcpy reads too much of a potentially nontermined src.
|
#
1.13 |
|
23-Jun-2003 |
tedu |
faster grep for simple patterns. derived from a patch by sean farley. this makes searching for constant strings much faster by avoiding regex. ok deraadt@
|
#
1.12 |
|
23-Jun-2003 |
deraadt |
minor tweaks
|
#
1.11 |
|
23-Jun-2003 |
tedu |
use strlcpy, not strncpy. ok deraadt@ millert@
|
#
1.10 |
|
23-Jun-2003 |
tedu |
spelling
|
#
1.9 |
|
23-Jun-2003 |
tedu |
better detetection/handling of binary files. make -a do the right thing, doc and implement -U, -I. add --help and --mmap for compatibility. some other minor fixes.
some from NetBSD. ok deraadt@
|
#
1.8 |
|
22-Jun-2003 |
tedu |
use __progname instead of progname. ok deraadt
|
#
1.7 |
|
22-Jun-2003 |
deraadt |
fix usage
|
#
1.6 |
|
22-Jun-2003 |
deraadt |
proper $OpenBSD$
|
#
1.5 |
|
22-Jun-2003 |
deraadt |
-DNOZ flag to be used by install media for removing z*grep support, if needed. (and knf)
|
#
1.4 |
|
22-Jun-2003 |
deraadt |
support z{e,f}grep
|
#
1.3 |
|
22-Jun-2003 |
deraadt |
freegrep 0.16
|
Revision tags: OPENBSD_3_3_BASE
|
#
1.2 |
|
16-Feb-2003 |
cloder |
Fix format string bug. I believe this grep is currently not used (in favor of the GNU version), but it gets fixed anyways. ok mickey@
|
Revision tags: OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE
|
#
1.1 |
|
21-Sep-2001 |
deraadt |
complete grep clone by harding@motd.ca; everything is there, but it is slow because libc regexp is slow. Anyone out there have the balls to sit down and optimize libc regexp?
|
#
1.57 |
|
10-Dec-2017 |
jmc |
- add max-count to SYNOPSIS - list long options with short, where they have an equivalent - sync usage() - minor tweaks
|
#
1.56 |
|
09-Dec-2017 |
pirofti |
Add support for the non-standard grep -m extension.
grep -m num stops after a maximum of num matches are found. We support -m0 to match GNU behaviour, but we do not allow negative numbers.
Manpage help from jmc@, OK deraadt@.
|
Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
|
#
1.55 |
|
28-Nov-2015 |
gsoares |
fix exit status on pledge(2) error, where it should be >1
OK millert@ deraadt@
|
#
1.54 |
|
09-Oct-2015 |
deraadt |
Change all tame callers to namechange to pledge(2).
|
#
1.53 |
|
03-Oct-2015 |
deraadt |
grep only opens files read-only, reads via stdio or other methods, performs computation, and outputs result to stdout. (note: in the tame model, malloc is implicit because stdio needs it, and mmap is implicit since malloc needs it; libz is satisfied by this environment also).
this tame change consists of 1 line, setting "stdio rpath" before getopt. this protection is fairly strict. grep could be improved further by computing a wpathlist based on argv, keeping -R in mind. feel free to take a shot at it.
grep was an early target of capsicum also. know anyone running capsicum grep?
ok doug
|
#
1.52 |
|
27-Aug-2015 |
dlg |
use strtonum to parse the number of lines of context.
this provides better error messages.
ok deraadt@ guenther@
|
Revision tags: OPENBSD_5_8_BASE
|
#
1.51 |
|
30-Apr-2015 |
millert |
Add warning when user specifies -R but no files, like GNU grep. OK schwarze@ ian@
|
#
1.50 |
|
16-Mar-2015 |
millert |
Don't include limits.h or sys/limits.h since grep.h already does it for us.
|
Revision tags: OPENBSD_5_7_BASE
|
#
1.49 |
|
10-Jan-2015 |
tedu |
1. They're flags, not counters. Set to one instead of incrementing. 2. The G flag is useless and never checked. Remove it. ok millert
|
#
1.48 |
|
01-Dec-2014 |
deraadt |
use reallocarray()
|
#
1.47 |
|
26-Nov-2014 |
millert |
Prefer setvbuf() to setlinebuf() for portability; ok deraadt@
|
#
1.46 |
|
26-Nov-2014 |
millert |
Make option string/struct const (since it is...). I've had this in my tree for ages.
|
Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
|
#
1.45 |
|
29-Dec-2012 |
millert |
Fix exit status when there is an error reading a file. Reported by Jeramey Crawford, fix adapted from FreeBSD. OK guenther@
|
Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
|
#
1.44 |
|
08-Jul-2011 |
tedu |
add support for -o to only print the match. reminded this was useful by ajcoutot
|
#
1.43 |
|
04-Mar-2011 |
tedu |
add -H (opposite of -h) to always print name. ok deraadt millert
|
Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
|
#
1.42 |
|
02-Jul-2010 |
tedu |
Remove the "fast" grep code if SMALL. This has the side effect of breaking fgrep -w, but oh well. ok deraadt millert
|
#
1.41 |
|
20-Apr-2010 |
jacekm |
Fix "grep -e foo -w" crash. The problem lies in 'e' getopt clause calling add_pattern, which in turn assumes that the getopt phase has already finished.
OK otto@
|
#
1.40 |
|
05-Apr-2010 |
tedu |
remove some non-POSIX standard non-GNU defacto standard options, mostly relating to symlinks that you can get with find. And a bonus fts flag fix. With a small tweak by guenther. ok deraadt guenther jmc millert nicm
|
Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
|
#
1.39 |
|
02-Sep-2007 |
deraadt |
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
|
Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
|
#
1.38 |
|
13-Feb-2007 |
kili |
- Be explicit on command line checking, instead of relying on patterns, which may be NULL (e.g. -e ''). - let add_pattern() decide how to deal with empty patterns, don't do magic in read_patterns().
This unbreaks stuff like grep -e '', and makes grep -f <file> more POSIX compliant. Semantics for grep -f /dev/null (or any other empty file) may be questionable, but this case isn't specified by POSIX, and matching nothing at all seems to be sane.
Thanks to otto@, who mentioned potential problems related to the -x option with the first patch i sent.
ok jaredy@ (some time ago), otto@, millert@
|
#
1.37 |
|
02-Nov-2006 |
ray |
Check length before checking index of len - 1.
OK moritz@.
|
#
1.36 |
|
26-Sep-2006 |
jaredy |
Allow zero-length patterns with -x so
$ grep -x ""
matches empty lines as reported on misc@ by Martin Marusak <marusak@fhpv.unipo.sk>. Initial diff by otto@ with tweaks by me.
ok otto
|
Revision tags: OPENBSD_4_0_BASE
|
#
1.35 |
|
07-Mar-2006 |
otto |
Break patterns containing newlines into multiple patterns like POSIX says. Report by Ralf dot Wildenhues at gmx dot de; testing by jmc@ ok beck@ millert@
|
Revision tags: OPENBSD_3_9_BASE
|
#
1.34 |
|
09-Feb-2006 |
otto |
delint; remove redundant vars and functions; ok jaredy@
|
Revision tags: OPENBSD_3_8_BASE
|
#
1.33 |
|
03-Apr-2005 |
jaredy |
Make the processing of patterns collected from files specified by -f delayed so options that affect pattern-building (such as -w) can be applied evenly to all such patterns.
ok and help otto, ok millert
|
#
1.32 |
|
03-Apr-2005 |
otto |
Protect begin and end of word markers added to the pattern when using the -w option with parentheses, to avoid operators in the expressions binding to the markers. Compare [[:<:]]foo|bar[[:>:]] and [[:<:]](foo|bar)[[:>:]]. Problem spotted by aaron@; ok millert@ aaron@ jaredy@
|
Revision tags: OPENBSD_3_7_BASE
|
#
1.31 |
|
03-Oct-2004 |
otto |
Remove block based mmap optimization. There are newline problems (PR 3940, 3941) which can be fixed, but if a match starts at the end of a block and continues into the next block, no match will be found. Measurements by millert@ showed that the improvements of this optimization are non-measurable anyway. Diff from Alexander Taler.
ok millert@
|
#
1.30 |
|
28-Sep-2004 |
jmc |
various fixes to make this page a bit clearer and hopefully a bit more helpful;
this includes some ideas/fixes from otto and jared;
|
Revision tags: OPENBSD_3_6_BASE
|
#
1.29 |
|
05-Aug-2004 |
deraadt |
spacing
|
#
1.28 |
|
07-May-2004 |
millert |
Add a new past path for fgrep that is just a simplified version of fastcomp. This makes fgrep faster and fixes the -w flag w/ fgrep. Also remove free_patterns() since calling free right before exit is silly. Problem noticed by espie@
|
#
1.27 |
|
02-Apr-2004 |
otto |
Implement --line-buffered ok millert@ tedu@
|
Revision tags: OPENBSD_3_5_BASE
|
#
1.26 |
|
04-Feb-2004 |
millert |
Fix anchors (^ or $) in -w mode broken by the last commit's -w overhaul. With this change we pass the updated regress. Tested and OK by ho@
|
#
1.25 |
|
25-Jan-2004 |
millert |
Previously, in -w mode, for each match on a line grep would check to see if the match was on a word boundary. However, this missed lines where the first match was not on a word boundary but a subsequent match was. Problem originally spotted by miod@
We fix this by using the [[:<:]] and [[:>:]] character classes for the slow path and by checking the word boundaries in grep_search() for the fast path instead of doing the checks after running regexec() or grep_search().
With this change, grep passes the new regress tests 15 and 16. problem originally spotted by espie@.
|
#
1.24 |
|
11-Dec-2003 |
mcbride |
Sync usage() with SYNOPSIS in grep(1).
ok deraadt@ jmc@
|
Revision tags: OPENBSD_3_4_BASE
|
#
1.23 |
|
07-Sep-2003 |
millert |
Fix "grep -number" support for multi-digit numbers. At issue is the fact that optind refers to the *next* argument to be consumed by getopt(), not the current one. This means we have to keep track of when we are working with a new argv entry by hand. OK hugh@
|
#
1.22 |
|
16-Jul-2003 |
millert |
When reallocing pattern, use sizeof(*pattern) not sizeof(int). Fixes a problem on sparc64 where sizeof(int) != sizeof(pointer). Based on a patch from Brian Poole; tedu@ OK
|
#
1.21 |
|
14-Jul-2003 |
millert |
range-check numeric arguments (-num, -A num, -B num)
|
#
1.20 |
|
10-Jul-2003 |
millert |
grep should exit(2) on error, not exit(1) (1 means no matches found). deraadt@ OK
|
#
1.19 |
|
10-Jul-2003 |
deraadt |
knf
|
#
1.18 |
|
10-Jul-2003 |
millert |
Fix parsing of -NUMBER. We now do things a digit at a time and keep track of what the last char from getopt was as well as the previous value of optind so we know when a new number has started.
|
#
1.17 |
|
25-Jun-2003 |
millert |
o remove useless cast to int from gzread() call o maxPatternLen should be size_t since that's what it is compared against o remove useless casts of NULL to various pointer types
|
#
1.16 |
|
24-Jun-2003 |
tedu |
actually do fgrep. -G -F and -E are now mutally exclusive, and override the program name as expected. ok millert@
|
#
1.15 |
|
23-Jun-2003 |
tedu |
strncpy -> memcpy per deraadt suggestion. also add a note why we can't use strlcpy.
|
#
1.14 |
|
23-Jun-2003 |
tedu |
go back to using strncpy. for long patterns, strlcpy reads too much of a potentially nontermined src.
|
#
1.13 |
|
23-Jun-2003 |
tedu |
faster grep for simple patterns. derived from a patch by sean farley. this makes searching for constant strings much faster by avoiding regex. ok deraadt@
|
#
1.12 |
|
23-Jun-2003 |
deraadt |
minor tweaks
|
#
1.11 |
|
23-Jun-2003 |
tedu |
use strlcpy, not strncpy. ok deraadt@ millert@
|
#
1.10 |
|
23-Jun-2003 |
tedu |
spelling
|
#
1.9 |
|
23-Jun-2003 |
tedu |
better detetection/handling of binary files. make -a do the right thing, doc and implement -U, -I. add --help and --mmap for compatibility. some other minor fixes.
some from NetBSD. ok deraadt@
|
#
1.8 |
|
22-Jun-2003 |
tedu |
use __progname instead of progname. ok deraadt
|
#
1.7 |
|
22-Jun-2003 |
deraadt |
fix usage
|
#
1.6 |
|
22-Jun-2003 |
deraadt |
proper $OpenBSD$
|
#
1.5 |
|
22-Jun-2003 |
deraadt |
-DNOZ flag to be used by install media for removing z*grep support, if needed. (and knf)
|
#
1.4 |
|
22-Jun-2003 |
deraadt |
support z{e,f}grep
|
#
1.3 |
|
22-Jun-2003 |
deraadt |
freegrep 0.16
|
Revision tags: OPENBSD_3_3_BASE
|
#
1.2 |
|
16-Feb-2003 |
cloder |
Fix format string bug. I believe this grep is currently not used (in favor of the GNU version), but it gets fixed anyways. ok mickey@
|
Revision tags: OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE
|
#
1.1 |
|
21-Sep-2001 |
deraadt |
complete grep clone by harding@motd.ca; everything is there, but it is slow because libc regexp is slow. Anyone out there have the balls to sit down and optimize libc regexp?
|