summaryrefslogtreecommitdiff
path: root/src/grep.h
Commit message (Collapse)AuthorAgeFilesLines
* maint: update copyright datesJim Meyering2023-01-011-1/+1
|
* Assume C23-like boolPaul Eggert2022-09-101-1/+0
| | | | | | Gnulib’s stdbool module now provides C23-like semantics, so there’s no longer any need to include stdbool.h. * src/die.h, src/grep.h, src/kwset.h: Don’t include stdbool.h.
* maint: make update-copyrightJim Meyering2022-01-011-1/+1
|
* grep: prefer signed to unsigned integersPaul Eggert2021-08-251-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This improves runtime checking for integer overflow when compiling with gcc -fsanitize=undefined and the like. It also avoids the need for some integer casts, which can be error-prone. * bootstrap.conf (gnulib_modules): Add idx. * src/dfasearch.c (struct dfa_comp, kwsmusts): (possible_backrefs_in_pattern, regex_compile, GEAcompile) (EGexecute): * src/grep.c (struct patloc, patlocs_allocated, patlocs_used) (n_patterns, update_patterns, pattern_file_name, poison_len) (asan_poison, fwrite_errno, compile_fp_t, execute_fp_t) (buf_has_encoding_errors, buf_has_nulls, file_must_have_nulls) (bufalloc, pagesize, all_zeros, fillbuf, nlscan) (print_line_head, print_line_middle, print_line_tail, grepbuf) (grep, contains_encoding_error, fgrep_icase_available) (fgrep_icase_charlen, fgrep_to_grep_pattern, try_fgrep_pattern) (main): * src/kwsearch.c (struct kwsearch, Fcompile, Fexecute): * src/kwset.c (struct trie, struct kwset, kwsalloc, kwsincr) (kwswords, treefails, memchr_kwset, acexec_trans, kwsexec) (treedelta, kwsprep, bm_delta2_search, bmexec_trans, bmexec) (acexec): * src/kwset.h (struct kwsmatch): * src/pcresearch.c (Pcompile, Pexecute): * src/search.h (mb_clen): * src/searchutils.c (kwsinit, mb_goback, wordchars_count) (wordchars_size, wordchar_next, wordchar_prev): Prefer idx_t to size_t or ptrdiff_t for nonnegative sizes, and prefer ptrdiff_t to size_t for sizes plus error values. * src/grep.c (uword_size): New constant, used for signed size calculations. (totalnl, add_count, totalcc, print_offset, print_line_head, grep): Prefer intmax_t to uintmax_t for wide integer calculations. (fgrep_icase_charlen): Prefer ptrdiff_t to int for size offsets. * src/grep.h: Include idx.h. * src/search.h (imbrlen): New function, like mbrlen except with idx_t and ptrdiff_t.
* maint: run "make update-copyright"Paul Eggert2021-01-011-1/+1
|
* maint: update all copyright year number rangesJim Meyering2020-01-011-1/+1
| | | | | | | | Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * doc/grep.in.1: Use "-" in copyright year ranges, not \en.
* maint: update all copyright dates via "make update-copyright"Jim Meyering2019-01-011-1/+1
| | | | * gnulib: Also update submodule for its copyright updates.
* maint: update gnulib and copyright dates for 2018Jim Meyering2018-01-061-1/+1
| | | | | | * gnulib: Update to latest. * all files: Run "make update-copyright". * bootstrap: Update from gnulib.
* maint: update gnulib and copyright dates for 2017Jim Meyering2017-01-011-1/+1
| | | | | * gnulib: Update to latest. * all files: Run "make update-copyright".
* grep: -P no longer uses PCRE_MULTILINEPaul Eggert2016-11-191-1/+0
| | | | | | | | | | | | | | | | | | This reverts commit f6603c4e1e04dbb87a7232c4b44acc6afdf65fef, as the extra performance is not worth the trouble for PCRE users. Problem reported by Stephane Chazelas in: http://bugs.gnu.org/22655#103 * NEWS: Document this and the next patch. * src/dfasearch.c (EGexecute): * src/grep.c (execute_fp_t): * src/kwsearch.c (Fexecute): * src/pcresearch.c (Pexecute): First arg is now a const pointer again. * src/grep.c (buf_has_encoding_errors): Now static. * src/grep.h (buf_has_encoding_errors): Remove decl. * src/search.h: Adjust decls. * src/pcresearch.c (reflags): Remove. All uses removed. (Pcompile, Pexecute): Do not use PCRE_MULTILINE.
* grep: print "filename:lineno:" in invalid-regex diagnosticJim Meyering2016-07-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Determining the file name and line number is a little tricky because of the way the regular expressions are all concatenated onto a newline- separated list. By the time grep would compile regular expressions, the <filename,lineno> origin of each regexp was no longer available. This patch adds a list of filename,first_lineno pairs, one per input source, by which we can then map the ordinal regexp number to a filename,lineno pair for the diagnostic. * src/dfasearch.c (GEAcompile): When diagnosing an invalid regexp specified via -f FILE, include the "FILENAME:LINENO: " prefix. Also, when there are two or more lines with compilation failures, diagnose all of them, rather than stopping after the first. * src/grep.h (pattern_file_name): Declare it. * src/grep.c: (struct FL_pair): Define type. (fl_pair, n_fl_pair_slots, n_pattern_files, patfile_lineno): Define globals. (fl_add, pattern_file_name): Define functions. (main): Call fl_add for each type of the following: -e argument, -f argument, command-line-specified (without -e) regexp. * tests/filename-lineno.pl: New file. * tests/Makefile.am (TESTS): Add it. * NEWS (Improvements): Mention this. Initially reported by Gunnar Wolf in https://bugs.debian.org/525214 Forwarded to grep's bug list by Santiago Ruano Rincón as http://debbugs.gnu.org/23965
* grep: restore -P PCRE_NO_UTF8_CHECK optimizationPaul Eggert2016-01-061-0/+2
| | | | | | | | | | | | | | | | | | On my platform in the en_US.utf8 locale, this makes 'grep -P "z.*a" k' 220x faster, where k is created by the shell command: yes 'abcdefg hijklmn opqrstu vwxyz' | head -n 10000000 >k * src/dfasearch.c (EGexecute): * src/grep.c (execute_fp_t): * src/kwsearch.c (Fexecute): * src/pcresearch.c (Pexecute): First arg is now char *, not char const *, since Pexecute now temporarily modifies this argument. * src/grep.c, src/grep.h (buf_has_encoding_errors): Now extern. * src/pcresearch.c (Pexecute): Use it. If the input is free of encoding errors, use a multiline search and the PCRE_NO_UTF8_CHECK option, as this is typically way faster. This restores an optimization that was removed with the recent changes for binary file detection.
* maint: update copyright year, bootstrap, init.shJim Meyering2016-01-011-1/+1
| | | | | | | | Run "make update-copyright" and then... * gnulib: Update to latest. * tests/init.sh: Update from gnulib. * bootstrap: Likewise.
* grep: be less picky about encoding errorsPaul Eggert2015-12-301-18/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a longstanding problem introduced in grep 2.21, which is overly picky about binary files. * NEWS: * doc/grep.texi (File and Directory Selection): Document this. * src/grep.c (input_textbin, textbin_is_binary, buffer_textbin) (file_textbin): Remove. All uses removed. (encoding_error_output): New static var. (buf_has_encoding_errors, buf_has_nulls, file_must_have_nulls): New functions, which reuse bits and pieces of the removed functions. (lastout, print_line_head, print_line_middle, print_line_tail, prline) (prpending, prtext, grepbuf): Avoid use of const, now that we have functions that require modifying a sentinel. (print_line_head): New arg LEN. All uses changed. (print_line_head, print_line_tail): Return indicator whether the output line was printed. All uses changed. (print_line_middle): Exit early on encoding error. (grep): Use new method for determining whether file is binary. * src/grep.h (enum textbin, TEXTBIN_BINARY, TEXTBIN_UNKNOWN) (TEXTBIN_TEXT, input_textbin): Remove decls. All uses removed. * src/pcresearch.c (Pexecute): Remove multiline optimization, since the main program no longer checks for encoding errors on input. * tests/encoding-error: New file. * tests/Makefile.am (TESTS): Add it.
* maint: update copyright year ranges to include 2015Jim Meyering2015-01-011-1/+1
| | | | | Run "make update-copyright". Also, ... * grep.texi: Update manually, converting each "--" to "-".
* grep: fix grep -P crashPaul Eggert2014-10-241-4/+0
| | | | | | | | | | | | | | Reported by Shlomi Fish in: http://bugs.gnu.org/18806 Commit 9fa500407137f49f6edc3c6b4ee6c7096f0190c5 (2014-09-16) is a hack that I put in to speed up 'grep -P'. Unfortunately, not only is it violation of modularity, it's also a bug magnet, as we have found out with Bug#18738 and Bug#18806. Remove the optimization instead of applying more bandaids. Perhaps we can think of a better way of doing the optimization, or perhaps we can just live with a slower grep -P (as -P is inherently slower anyway...). * src/grep.c, src/grep.h (validated_boundary): Remove. All uses removed. * src/pcresearch.c (Pexecute): Do not worry about validated_boundary.
* grep: skip past holes efficientlyPaul Eggert2014-09-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Take advantage of the relaxed rules for treating non-text bytes in binary data, by efficiently skipping past holes on platforms supporting lseek's SEEK_DATA flag. On one test on a circa-2008 Sun Fire V40z running Solaris 11.2, 'grep x' took 0.009 real-time seconds to scan a holey file of size 9,223,372,036,854,775,802 bytes, for a nominal scan rate of 1 ZB/s. grep 2.20's scan rate on this platform was 843 MB/s, so this is a speedup by a factor of 1.2 trillion. The speedup factor is not as great on GNU/Linux hosts, due to what appear to be SEEK_DATA inefficiencies, but presumably this will be cleared up in time. * NEWS: Document this. * src/grep.c, src/grep.h (eolbyte): Now char, not unsigned char. This is for compatibility with the rest of the code. The old (performance?) reasons for 'unsigned char' are now moot. * src/grep.c (skip_nuls, skip_empty_lines, seek_data_failed): New static vars. (totalnl): Move up, since it's about input, not output, and fillbuf now uses it. (add_count): Move up, since fillbuf now uses it. (all_zeros): New function. (fillbuf): Use SEEK_DATA to skip past holes efficiently, on systems that support this. (grep, main): Set the new static vars.
* grep: improve -P performance in typical casesPaul Eggert2014-09-171-0/+22
| | | | | | | | | | * src/grep.c, src/grep.h (enum textbin): Move to grep.h. (input_textbin, validated_boundary): New vars. * src/grep.c (grepbuf, grep): Initialize them. * src/pcresearch.c (Pexecute): Do a multiline search when the input is known to be free of encoding errors. Quickly discard bytes that are obviously encoding errors. Quickly match empty strings.
* grep: use bool for boolean in grep.cPaul Eggert2014-09-161-3/+5
| | | | | | | | | | | | | | * src/grep.c (show_version, suppress_errors, only_matching) (align_tabs, match_icase, match_words, match_lines, errseen) (write_error_seen, is_device_mode, usable_st_size) (file_is_binary, skipped_file, reset, fillbuf, out_quiet) (out_line, out_byte, count_matches, no_filenames, line_buffered) (done_on_match, exit_on_match, print_line_head, prline, grep) (grepdirent, grepfile, grepdesc, grep_command_line_arg) (get_nondigit_option, main): Use bool for boolean. (print_line_head, prline): Use char for byte. * src/grep.h: Include <stdbool.h>, and adjust decls to match changes in grep.c.
* egrep, fgrep: go back to shell scriptsPaul Eggert2014-03-231-17/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although egrep's and fgrep's switch from shell scripts to executables may have made sense in 2005, it complicated maintenance and recently has caused subtle performance bugs. Go back to the old way of doing things, as it's simpler and more easily separated from the mainstream implementation. This should be good enough nowadays, as POSIX has withdrawn egrep/fgrep and portable applications should be using -E/-F anyway. * po/POTFILES.in: Remove src/egrep.c, src/fgrep.c, src/main.c. * src/Makefile.am (bin_PROGRAMS): Remove egrep, fgrep. (bin_SCRIPTS): New macro. (grep_SOURCES): Move searchutils.c, dfa.c, dfasearch.c, kwset.c, kwsearch.c, pcresearch.c here from libgrep_a_SOURCES. (egrep_SOURCES, fgrep_SOURCES, noinst_LIBRARIES, libgrep_a_SOURCES): Remove. (LDADD): Remove libgrep.a. (egrep, fgrep): New rules. (CLEANFILES): New macro. * src/grep.c: Rename from src/main.c. (usage, setmatcher, main): Simplify, since there's now just one executable. (Gcompile, Ecompile, Acompile, GAcompile, PAcompile, matchers): Move here from the (removed) src/grep.c. (compile_fp_t, execute_fp_t, struct matcher, matchers): Move here from src/grep.h, as they no longer need to be public. (struct matcher.name): Avoid one level of indirection/relocation. (do_execute, main): Fix a performance bug when it was compiled as 'fgrep', due to confusion about which matcher was which. (main): Fix a performance bug with -P, likewise. * src/grep.h (before_options, after_options): Remove. * src/egrep.c, src/fgrep.c, src/grep.c: Remove.
* maint: update copyright dates for 2014Jim Meyering2014-01-011-1/+1
| | | | Do that by running "make update-copyright".
* maint: update all copyright year number rangesJim Meyering2013-01-041-1/+1
| | | | Run "make update-copyright".
* maint: use gnulib _Noreturn rather than __attribute__ ((noreturn))Paul Eggert2012-02-291-4/+0
| | | | | | | * src/grep.h (__attribute__): Remove. * src/dfa.h (__attribute__): Likewise. (dfaerror): Use noreturn rather than __attribute__ ((noreturn)). * src/main.c (usage): Likewise.
* maint: update all copyright year number rangesJim Meyering2012-01-011-1/+1
| | | | Run "make update-copyright".
* maint: use consistent declaration syntaxJim Meyering2011-05-081-2/+3
| | | | | * src/grep.h (matchers): Declare consistently, so the sc_tight_scope rule detects this as an extern-marked variable.
* maint: update copyright year ranges to include 2011Jim Meyering2011-01-031-1/+1
| | | | Run "make update-copyright", so "make syntax-check" works in 2011.
* grep: add include guardsPaolo Bonzini2010-11-141-0/+5
| | | | | * src/system.h: Add multiple inclusion guards. * src/grep.h: Likewise.
* grep: diagnose and exit-2 for bogus REs like [:space:], [:digit:], etc.Jim Meyering2010-09-011-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When I make a mistake like this: grep '[:lower:]' ... be it in a script or on the command line, I want to know about it as soon as possible. I don't want grep to print a mere warning that it is interpreting this suspicious and almost guaranteed-wrong regular expression as a set of just 6 bytes. And I certainly don't want grep to silently do the wrong thing, even if that would be officially standards-conforming. It's obvious that I intended [[:lower:]], and I want my error to be diagnosed in a way that is most likely to get my attention. Thus, with this change, grep now prints a diagnostic and exits with status 2 the moment it encounters an offending [:char_class:] construct. This changes the way grep works by default, rather than putting this new behavior on an option. A new option would seldom be used in scripts (not portable), and would probably be used only rarely by those who need it the most. This new functionality provides a valuable safety measure and incurs truly negligible risk. For strict POSIX compliance, set POSIXLY_CORRECT in your environment. That disables this new feature. Revert the changes from commit 2cd3bcea, "grep: add --warnings={always,never,auto}.", and then do the following: * src/dfasearch.c (dfawarn): Call getenv("POSIXLY_CORRECT") here; Remove "warning: " from the diagnostic, now that it's more than a warning, and exit with status 2. * NEWS (New features): Describe the new semantics. * tests/warn-char-classes: Adjust one test to accommodate this change. * doc/grep.texi (Character Classes and Bracket Expressions): Document. (Environment Variables): Cross-reference it. Remove reference to obsolete getopt illegal vs. invalid difference. Thanks to Paul Eggert for suggestions and an initial prod.
* grep: add --warnings={always,never,auto}.Paolo Bonzini2010-08-271-0/+2
| | | | | | | * src/grep.h (no_warnings): New declaration. * src/main.c (no_warnings): New. (WARNINGS_OPTION): Add to enum. (main): Add --warnings. Handle color_option == 2 together with it.
* grep: kill GREP_PROGRAM/EGREP_PROGRAM/FGREP_PROGRAMPaolo Bonzini2010-03-221-8/+3
| | | | | | | | | | | | | | | | | | | | | * NEWS: Document slight semantic change. * TODO: #ifdefs are gone. * po/POTFILES.in: Update. * src/Makefile.am (grep_SOURCES, egrep_SOURCES, fgrep_SOURCES): Remove grep.c/egrep.c/fgrep.c. (noinst_LIBRARIES): Change libsearch.a to libgrep.a. (libsearch_a_SOURCES): Rename to libgrep_a_SOURCES, add grep.c (LDADD): Change libsearch.a to libgrep.a. * src/esearch.c: Add before_options and after_options. * src/fsearch.c: Likewise. * src/gsearch.c: Likewise. * src/grep.c (short_options, long_options): Remove GREP_PROGRAM special-casing. (usage): Use before_options and after_options, look at matchers. (setmatcher): Merge with install_matcher. (main): Call setmatcher (NULL) instead of install_matcher. * src/grep.h (GREP_PROGRAM): Remove. (before_options, after_options): Add.
* grep: eliminate {COMPILE,EXECUTE}_{RET,ARGS,FCT}Paolo Bonzini2010-03-221-14/+2
| | | | | | | | | | | Modern compilers warn about type mismatches. * src/grep.c (do_execute): Write full declaration. * src/grep.h (COMPILE_RET, COMPILE_ARGS, COMPILE_FCT, EXECUTE_RET, EXECUTE_ARGS, EXECUTE_FCT): Remove. (compile_fp_t, execute_fp_t): Write full declaration. * src/search.c (GEAcompile, Gcompile, Acompile, Ecompile, EGexecute, Fcompile, Fexecute, Pcompile, Pexecute): Write full declaration.
* grep: make egrep/fgrep use struct matcherPaolo Bonzini2010-03-221-14/+3
| | | | | | | | | | | | | * Makefile.am (grep_SOURCES): Add gsearch.c. (EXTRA_DIST): Add search.c. * esearch.c (matchers): New. * fsearch.c (matchers): New. * gsearch.c: New. * search.c (matchers): Remove. * grep.c: Always compile most !GREP_PROGRAM sections. (main): Use first matcher if none is explicitly provided. Remove "default" matcher. * grep.h (struct matcher): Adjust comments.
* grep: change struct matcher terminationPaolo Bonzini2010-03-221-2/+2
| | | | | | * src/grep.c (setmatcher): Look for NULL matchers[i].name. * src/grep.h (struct matcher): Change name to pointer. Adjust comments. * src/search.c (matchers): Terminate with three NULLs.
* maint: remove all uses of PARAMSJim Meyering2010-03-111-4/+4
| | | | | | | | | | | * lib/savedir.h (PARAMS): Remove definitions manually. Remove the remaining ones via this command: git grep -l define.PARAMS |xargs perl -ni -e '/define PARAMS/ or print' * src/dfa.h (PARAMS): Remove definitions. * src/system.h (PARAMS): Likewise. Remove most uses with this: git grep -lw PARAMS |xargs perl -pi -e 's/\bPARAMS *\((.*)\);/$1;/' Remove the remainder manually.
* maint: update all FSF copyright year lists to include 2010Jim Meyering2010-01-011-1/+2
| | | | | | Use this command: git ls-files |grep -vE '^(\..*|COPYING|gnulib)$' |xargs \ env UPDATE_COPYRIGHT_USE_INTERVALS=1 build-aux/update-copyright
* update/add copyright noticesKarl Berry2009-01-301-1/+1
|
* GPLv2 -> GPLv3Bernhard Rosenkraenzer2007-06-281-1/+1
|
* The introduction of the --only-matching and --color GNU extensionsCharles Levert2005-11-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to grep added the requirement that each execute() implementation not only be able to identify matching lines as a whole, but also individual "exact" matches within a line known to be matching, from leftmost to rightmost match, when the output from matching lines is actually produced. The interface and implementations of execute() were not up to it. This set of changes aims to rectify that situation. Previously failing tests relative to left anchors (^ and \<) and -w should now pass. This fixes <http://savannah.gnu.org/bugs/?func=detailitem&item_id=11579>, <http://savannah.gnu.org/patch/?func=detailitem&item_id=1834>, <http://savannah.gnu.org/bugs/?func=detailitem&item_id=8243>, and possibly part of other, bigger, pending patches. The problem was also compounded by the POSIX requirement to support a pattern list instead of just an individual pattern (for -G and -E as well). * tests/foad1.sh: Test for increasing/decreasing-length word matches, given pattern order, and leftmost/longest match. * tests/fmbtest.sh: Modify test #6 according to new expectations. Better document what tests #6 and #7 are actually for. Eliminate test #5 in favor of bringing tests #6 and #7 within the F G E loop. * src/grep.h (EXECUTE_ARGS): Change last argument from "int exact" to "char const *start_ptr". Testing for "start_ptr" being non-NULL retains the same semantics as testing for "exact" being non-zero. * src/grep.c (print_line_middle): Call execute() with whole buffer to work on, but using current position as start_ptr. * src/grep.c (prpending, grepbuf): Call execute() with NULL as start_ptr. * src/search.c (EGexecute, Fexecute, Pexecute): When start_ptr is non-NULL, return first match from it as an offset relative to buf. * src/search.c (EGexecute): Consider all patterns if many and, for an exact match, return the best one (leftmost, then longest). Don't explore worst solutions, of course (branch and bound).
* The following set of changes aims to make "egrep" and "fgrep"Charles Levert2005-11-091-6/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | minimal executable programs for legacy applications, instead of shell scripts. This "fgrep" is much smaller than "grep". This set of changes appears more daunting than it really is. * src/egrep.c, src/fgrep.c, src/esearch.c, src/fsearch.c: New files that #define either EGREP_PROGRAM or FGREP_PROGRAM and #include the corresponding generic (i.e., non e or f specific) *.c file. * src/grepmat.c: Remove whole file. * src/Makefile.am: Remove no-dependencies from AUTOMAKE_OPTIONS. Add definitions to make "egrep" and "fgrep" specific standalone executable programs that only use the source files they need. Remove rules for "egrep" and "fgrep" shell scripts. * src/grep.h: #define GREP_PROGRAM if both EGREP_PROGRAM and FGREP_PROGRAM are #undef. Only declare matchers[] in this case along with the compile_fp_t and execute_fp_t function pointers typedefs, otherwise declare prototypes for straight compile() and execute() functions for the specialized "egrep" and "fgrep" programs. Remove the extern declaration for matcher. Define COMPILE_RET, COMPILE_ARGS, EXECUTE_RET, EXECUTE_ARGS, COMPILE_FCT, and EXECUTE_FCT helper preprocessor macros. * src/grep.c (short_options, long_options, usage, main): Only support -G, -E, -F, -P, and -X for GREP_PROGRAM, but not for EGREP_PROGRAM or FGREP_PROGRAM. Customize usage messages. * src/grep.c (set_limits): New function with unchanged code, called from main(), because it shouldn't be in install_matcher() since it was already matcher-independent. * src/grep.c (matcher): Add as static, only for GREP_PROGRAM. * src/grep.c (setmatcher, install_matcher): Only for GREP_PROGRAM. * src/grep.c (main): Remove any tweaking and dependence on argv[0]. * src/grep.c (print_line_middle, prpending, grepbuf, main): Call compile() and execute() directly, not through a function pointer dereferencing notation, so that it works with both straight functions (in EGREP_PROGRAM and FGREP_PROGRAM) and function pointers (in GREP_PROGRAM). * src/search.c (<regex.h>, "dfa.h", dfa, pattern0, patterns, pcount, dfaerror, kwset_exact_matches, kwsmusts): Only include/declare/define if not FGREP_PROGRAM. * src/search.c: Remove function prototypes for all functions that are not used before their definition, since this is just a hassle now with their varying names and conditional definition. * src/search.c (GEAcompile): Rename from Ecompile(). Add new syntax_bits argument/variable. Use as compile() for EGREP_PROGRAM. Put in the needed RE_ICASE fix, albeit commented-out for now. Make sure to free() modified word/line pattern after use, if any. * src/search.c (Gcompile): Merge with GEAcompile() then remove. * src/search.c (Gcompile, Acompile, Ecompile): New small functions that call GEAcompile(), now that matcher is not an extern variable. * src/search.c (GEAcompile, Gcompile, Acompile, Ecompile, Fcompile, Pcompile, EGexecute, Fexecute, Pexecute, matchers): Only define when needed according to *GREP_PROGRAM, and rename to just compile() and execute() when appropriate. * grep/bootstrap/Makefile.try: Similar changes.
* * README.DOS, TODO, grep.spec, doc/grep.1, doc/grep.texi,Charles Levert2005-11-081-1/+1
| | | | | | | | | | | | src/grep.h, po/da.po, po/nb.po, po/no.po, po/sv.po: Replace all capitalized "Grep" by a lowercase "grep", except in citations. Reported by Benno Schulenberg <benno@nietvergeten.nl> from the <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=190551> entry in the Debian bug tracker. * doc/grep.1, doc/grep.texi: Explain that the "egrep" and "fgrep" commands are deprecated and provided for historical applications. Replace some "egrep" uses by "grep -E" to promote the newer usage. Typeset "zgrep" as a command. Fix some spacing and punctuation bugs.
* Update FSF's civic address, zip code, and citizen relocation code.Charles Levert2005-05-021-2/+2
| | | | | * 78 files: Update FSF's civic address, zip code, and citizen relocation code.
* much of the supporting files moved to libAlain Magloire2001-03-041-4/+0
|
* hilight.Alain Magloire2001-02-091-2/+2
| | | | | | | | | | | | | Patch from Ulrich Drepper to provide hilighting * src/grep.c : New option --color. (color) : New static var. (COLOR_OPTION) : new constant. (grep_color) : new static var. (prline) : Now when color is set prline() will call the current matcher to find the offset of the matching string. * src/savedir.c : Take advantage of _DIRENT_HAVE_TYPE if supported. * src/search.c (EGexecute, Fexecute, Pexecute): Take a new argument when doing exact match for the color hiligting.
* Remove sentinel code.Alain Magloire2001-02-081-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that we know that the input is always terminated by a newline before the matching algorithms see it, clean up the matching algorithms so that they no longer need to modify the input by inserting a sentinel newline, and no longer worry about running off the end of the buffer due to a missing sentinel. * src/grep.c (nlscan, prpending, prtext, grepbuf): Do not worry about running off the end of the input buffer, since it's now guaranteed to end in the sentinel newline. * src/search.c (EGexecute, Pexecute): Likewise. * src/dfa.c (prtok, dfasyntax, dfaparse, copy, merge, state_index, epsclosure, dfaexec, dfacomp): Change many instances of "T *" to "T const *", to catch any inadvertent programming errors made during this conversion. * src/dfa.h (dfacomp, dfaexec, dfaparse): Likewise. * src/grep.c (struct stats.parent, long_options, grepdir, compile, execute, fillbuf, lastnl, lastout, nlscan, prline, prpending, prtext, grepbuf, grep, grepfile, grepdir): Likewise. * src/grep.h (struct matcher.compile, struct matcher.execute): Likewise. * src/kwset.c (struct kwset.trans, kwsalloc, kwsincr, treefails, treedelta, hasevery, treenext, bmexec, cwexec, kwsexec): Likewise. * src/kwset.h (kwsalloc, kwsincr, kwsexec): Likewise. * src/search.c (kwsmusts, Gcompile, Ecompile, EGexecute, Pcompile, Pexecute): Likewise. * src/dfa.c (dfaexec): Use size_t, not char *, to avoid worrisome casts to convert char const * to char *. * src/dfa.h (dfaexec): Likewise. * src/grep.c (execute): Likewise. * src/grep.h (execute): Likewise. * src/kwset.c (bmexec, cwexec, kwsexec): Likewise. * src/kwset.h (struct kwsmatch.offset, kwsalloc, kwsincr, kwsexec): Likewise. * src/search.c (EGexecute, Fexecute, Pexecute): Likewise. * src/dfa.h (_PTR_T): Depend on defined __STDC__, not __STDC__. (PARAMS): Depend on PROTOTYPES, not __STDC__. * src/dfa.c (dfasyntax): Last arg is unsigned char, not int. * src/dfa.h (dfasyntax): Likewise. * src/dfa.h (struct dfa): Remove member newlines; no longer needed. * src/dfa.c (build_state, dfaexec, dfafree): Do not worry about special newline state. * src/search.c (matchers): Move definition to end of file, so that we don't need forward decls. (lastexact): Remove. (kwset_exact_matches): New var; subsumes old lastexact var. All uses changed. * src/dfa.c (index): Remove macro. (REALLOC_IF_NECESSARY): Skip unnecessary test. (tstbit, setbit, clrbit): Declare arg to be unsigned, to help compiler. (copyset, zeroset, equal): Use C builtin primitives, to help compiler. (dfaexec): Do not modify input string. Remove newline parameter; no longer needed. (comsubs): Use strchr, not index. * src/grep.h (matchers): Use fixed name size, not pointer (as there's no need for the extra flexibility). All uses changed. * src/kwset.h (struct kwsmatch.offset): Renamed from beg, with change of type to size_t. All uses changed. * src/grep.c (reset): No longer need kludge for dfaexec. Simplify. (reset, grepbuf): Adjust to new interface for 'execute'. (install_matcher): List is now terminated by null compile, not null name. Do not invoke setrlimit if that wouldn't change the limit. * src/dfa.c (xcalloc, xmalloc, xrealloc, prtok, tstbit, setbit, clrbit, copyset, zeroset, notset, equal, charclass_index, looking_at, lex, addtok, atom, nsubtoks, copytoks, closure, branch, regexp, copy, insert, merge, delete, state_index, build_state, build_state_zero, icatalloc, icpyalloc, istrstr, ifree, freelist, enlist, comsubs, addlists, inboth): Remove forward decls; no longer needed. * src/grep.c (ck_atoi, usage, error, setmatcher, install_matcher, prepend_args, prepend_default_options, page_alloc, reset, fillbuf, grepbuf, prtext, prpending, prline, print_offset_sep, nlscan, grep, grepfile): Likewise. * src/kwset.c (enqueue, treefails, treedelta, hasevery, treenext, bmexec, cwexec): Likewise. * src/search.c (Gcompile, Ecompile, EGexecute, Fcompile, Fexecute, Pcompile, Pexecute, kwsinit): Likewise. * src/search.c (Pcompile): Do not assume newly allocated storage is zeroed.
* make egrep == grep -E.Alain Magloire1999-10-061-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bugfixes Accept a patch from Paul to make egrep == grep -E. added new tests * NEWS: egrep is now equivalent to `grep -E'. The lower bound of an interval is not optional. You can specify a matcher multiple types without error. -u and -U are now allowed on non-DOS hosts, and have no effect. * doc/grep.texi: Likewise. * doc/grep.1: Likewise. Fix some troff bugs that prevented `groff' from rendering the page. * src/egrepmat.c, src/fgrepmat.c, src/grepmat.c (default_matcher): Remove. (matcher): Add. * src/grep.h (default_matcher): Remove. (matcher): Now exported from ?grepmat.c, not grep.c. * src/dfa.c (lex): If { would start an invalid interval specification, * src/grep.c (short_options): New constant. (long_options, main): -u and -U are now supported on Unix, with no effect. (matcher): Removed; now defined by ?grepmat.c. (install_matcher): Renamed from setmatcher. (setmatcher): New function. (usage): Report new, more uniform option scheme. (main): Do not initialize matcher; ?grepmat.c now does this. Rely on setmatcher to catch matcher conflicts. Default matcher is "grep". * src/search.c (matchers): Remove "posix-egrep" matcher; no longer needed. (Ecompile): Likewise. The egrep matcher now has POSIX behavior. * tests/bre.tests: grep '\{' is no longer an error. Fix test for interval too large, and enable it. * tests/ere.tests: grep -E {1 is no longer an error Likewise for a{1, a{1a, a{1a}, a{1,x}.
* change by Paul Eggert.Alain Magloire1999-08-131-0/+1
| | | | | change by Paul Eggert. change by Paul Eggert.
* Entry form Paul.Alain Magloire1998-11-171-1/+5
| | | | | | Use the attribute keyword from gcc to eliminate warnings. * dfa.c (dfacomp), search.c (EGexecute): Don't assume char is unsigned.
* changes by paul to replace matcher=MATCHER scheme.Alain Magloire1998-11-101-1/+4
|
* updateAlain Magloire1998-11-081-5/+5
| | | | | | | | | use our own instead of default. now don't rely on matcher = argv[0] set explicitly at compilation. * src/grep.c: The Matcher is not set to argv[0] but explicitly by a #define MATCHER at compile time default is "grep".
* Initial revisionAlain Magloire1998-11-031-0/+41