summaryrefslogtreecommitdiffstats
path: root/usr.bin/grep (follow)
Commit message (Collapse)AuthorAgeFilesLines
* zlib functions take a gzFile not gzFile * (gzFile is already a pointer).millert2021-03-103-7/+7
| | | | From Josh Rickmar.
* Change line counter from int to unsigned long long to reduce overflow.martijn2020-07-232-8/+12
| | | | | | | | | 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
* With -R and an implicit ".", don't prepend file paths with "./"jca2019-12-032-10/+14
| | | | | Looks nicer and matches the output of GNU grep. ok millert@ deraadt@ visa@ miod@
* Document implicit "." default file for -Rkn2019-12-031-2/+7
| | | | OK visa deraadt
* With -R assume that "." was passed instead of printing a warningjca2019-12-021-3/+7
| | | | | Saner default behavior that matches GNU grep. Diff from miod@, support from espie@, ok visa@ millert@
* jmc is a stickler for consistency.tedu2019-10-071-3/+3
|
* add --label to usage. thx jmctedu2019-10-071-2/+2
|
* two compat features to allow the zstdgrep script to work.tedu2019-10-074-6/+25
| | | | | | add --label option to prefix the output instead of filename. allow using - to mean stdin. ok deraadt
* Delete documentation of --max-count, which is merely an alias ofschwarze2019-07-182-6/+5
| | | | | | | | | | | | | | 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.
* when combining -o and -b, print the byte offset of the pattern, not line.tedu2019-07-172-6/+9
| | | | originally from chrisz
* convert fgetln to getline. this improves portability and sets a goodtedu2019-01-312-11/+19
| | | | | | | | 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.
* mmap support was broken in previous submitted diff from lauri tirkkonenderaadt2019-01-271-1/+2
|
* rework grep_open to be more careful about directories.tedu2019-01-235-64/+53
| | | | | cleaner, but should be no functional change. from Lauri Tirkkonen
* - add max-count to SYNOPSISjmc2017-12-102-19/+14
| | | | | | - list long options with short, where they have an equivalent - sync usage() - minor tweaks
* Add support for the non-standard grep -m extension.pirofti2017-12-094-12/+43
| | | | | | | | 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@.
* initialize regmatch_t always, fixes grep -o ""tedu2017-04-031-2/+2
| | | | from Michael Santos
* when using -o, we may restart a match in the middle of the line.tedu2016-08-251-5/+14
| | | | | | set NOTBOL so that anchored patterns don't match. from a patch by Daniƫl de Kok in freebsd bug 201650 ok martijn
* Reverse search optimization makes no sense (and doesn't work) ifotto2016-04-041-2/+2
| | | | we are looking for all matches in a line; ok natano@ miilert@ tedu@
* for some time now mandoc has not required MLINKS to functionjmc2016-03-301-7/+1
| | | | | | | | | | | | correctly - logically complete that now by removing MLINKS from base; authors need only to ensure there is an entry in NAME for any function/ util being added. MLINKS will still work, and remain for perl to ease upgrades; ok nicm (curses) bcook (ssl) ok schwarze, who provided a lot of feedback and assistance ok tb natano jung
* cast toupper's argument to unsigned charmmcc2015-12-221-2/+2
| | | | ok millert@
* The loop index in grep_cmp() should be size_t to match the type ofmillert2015-12-221-11/+11
| | | | | | the length parameter. The return value of grep_cmp() is only used in a boolean context so make it return bool instead of the index. OK mmcc@
* Use long long rather than off_t for line_no to ensure that it's alwaysmmcc2015-12-142-4/+4
| | | | | | 64 bits. ok kettenis@
* Represent line numbers with off_t rather than int. This preventsmmcc2015-12-072-4/+4
| | | | overflow on huge inputs. ok millert@, deraadt@
* fix exit status on pledge(2) error, where it should be >1gsoares2015-11-281-2/+2
| | | | OK millert@ deraadt@
* Change all tame callers to namechange to pledge(2).deraadt2015-10-091-3/+3
|
* grep only opens files read-only, reads via stdio or other methods, performsderaadt2015-10-031-1/+4
| | | | | | | | | | | | | | | 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
* use strtonum to parse the number of lines of context.dlg2015-08-271-10/+9
| | | | | | this provides better error messages. ok deraadt@ guenther@
* Put fts_close() where missing.uebayasi2015-06-251-2/+2
| | | | | | | | | | Not bugs in short-lived commands that call exit() -> _exit() immediately, but for idempotency. Originally found in ls(1) by Valgrind. Changes for other commands are from deraadt@. Reviewed by me, tested in snapshots. OK deraadt@
* Add warning when user specifies -R but no files, like GNU grep.millert2015-04-301-1/+3
| | | | OK schwarze@ ian@
* Don't include limits.h or sys/limits.h since grep.h already does itmillert2015-03-162-4/+2
| | | | for us.
* Include limits.h, not sys/limits.h and include stdint.h for SIZE_MAX.millert2015-03-161-2/+3
|
* SIZE_MAX is standard, we should be using it in preference to themillert2015-02-061-2/+2
| | | | obsolete SIZE_T_MAX. OK miod@ beck@
* Replace <sys/param.h> with <limits.h> and other less dirty headers wherederaadt2015-01-163-9/+5
| | | | | | | | | possible. Annotate <sys/param.h> lines with their current reasons. Switch to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where sensible to avoid pulling in the pollution. These are the files confirmed through binary verification. ok guenther, millert, doug (helped with the verification protocol)
* An article on medium.com highlighted that grepdaniel2015-01-131-3/+3
| | | | | | | | | was available in v4. To quote Ken Thompson, grep appeared "sometime before the 4th edition." ok schwarze@
* 1. They're flags, not counters. Set to one instead of incrementing.tedu2015-01-102-23/+15
| | | | | 2. The G flag is useless and never checked. Remove it. ok millert
* use reallocarray()deraadt2014-12-013-5/+15
|
* Prefer setvbuf() to setlinebuf() for portability; ok deraadt@millert2014-11-261-2/+2
|
* Make option string/struct const (since it is...). I've had thismillert2014-11-261-4/+4
| | | | in my tree for ages.
* Check the mode flag being passed in to mmopen() instead of ignoring it.brad2014-11-081-3/+3
| | | | | | | | Pointed out by LLVM. mmfile.c:51:7: warning: explicitly assigning a variable of type 'char *' to itself [-Wself-assign] ok millert@
* Use errc/warnc to simplify code.guenther2014-05-201-2/+2
| | | | | | Also, in 'ftp', always put the error message last, after the hostname/ipaddr. ok jsing@ krw@ millert@
* unsigned char casts for ctypederaadt2013-11-262-5/+5
| | | | ok krw
* simple prototype repairsderaadt2013-11-121-2/+2
|
* blacklist a select few characters instead of a limited whitelist fortedu2013-05-041-11/+21
| | | | | detecting non-regex patterns. makes the fast grep code more applicable. with some improvements by Jeremie Courreges-Anglas
* remove uesless Pp;jmc2013-01-171-3/+2
|
* Fix exit status when there is an error reading a file.millert2012-12-293-6/+10
| | | | | Reported by Jeramey Crawford, fix adapted from FreeBSD. OK guenther@
* Don't print zero length matches in -o mode. Found by otto@ whomillert2012-12-121-2/+2
| | | | initially proposed a different fix. OK otto@
* use proper eol offset for -o matching; spotted by ajacoutot@; ok millert@otto2012-12-111-2/+2
|
* Fix an integer overflow for very long lines by replacing the datatype of 2 offsets from int to regoff_t.aschrijver2011-07-171-3/+9
| | | | | | | | | | | Bail if the given size_t line length doesn't fit into the new regoff_t. "I don't think you will ever be able to get a string longer than SSIZE_MAX into memory, but that looks good." tedu@ "Agreed" otto@ regoff_t suggested by otto@
* Fix spacingaschrijver2011-07-171-4/+4
| | | | OK otto@
* the matchall magic shortcut requires we set c=1 to print nowtedu2011-07-111-1/+2
| | | | fixes libpqxx build