summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* maint: update all FSF copyright year lists to include 2010Jim Meyering2010-01-0114-22/+18
| | | | | | Use this command: git ls-files |grep -vE '^(\..*|COPYING|gnulib)$' |xargs \ env UPDATE_COPYRIGHT_USE_INTERVALS=1 build-aux/update-copyright
* fix multi-byte-locale read-beyond-end-of-buffer errorJim Meyering2009-12-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Avoid read-beyond-end-of-buffer errors, evoked by running this: LC_ALL=en_US.UTF-8 valgrind src/grep -f <(printf 'a\nb\n') <(echo c) Conditional jump or move depends on uninitialised value(s) at 0x78136D: __gconv_transform_utf8_internal (in /lib/libc-2.11.so) by 0x7E7232: mbrtowc (in /lib/libc-2.11.so) by 0x8055773: dfaexec (dfa.c:2816) by 0x804D7B0: EGexecute (search.c:353) by 0x804ACD8: grepbuf (grep.c:1036) by 0x804B023: grep (grep.c:1156) by 0x804B460: grepfile (grep.c:1287) by 0x804CF0D: main (grep.c:2282) Conditional jump or move depends on uninitialised value(s) at 0x7E7248: mbrtowc (in /lib/libc-2.11.so) by 0x8055773: dfaexec (dfa.c:2816) by 0x804D7B0: EGexecute (search.c:353) by 0x804ACD8: grepbuf (grep.c:1036) by 0x804B023: grep (grep.c:1156) by 0x804B460: grepfile (grep.c:1287) by 0x804CF0D: main (grep.c:2282) * src/dfa.c (dfaexec) [MBS_SUPPORT]: Do not access one byte beyond end of buffer.
* Speed up insert.Paolo Bonzini2009-12-231-13/+16
| | | | | | Suggested by Johan Walles <johan.walles@gmail.com> (bug 23354). * src/dfa.c (insert): Use binary search.
* Decrease epsclosure memory usageJohan Walles2009-12-231-2/+2
| | | | | | Fixes bug 23321. * src/dfa.c (epsclosure): Make visited an array of char.
* Make 'grep -1 -2' and 'grep -1v2' equivalent to grep -2Paolo Bonzini2009-12-221-7/+19
| | | | | | | Fixes bug 12128. * src/grep.c (get_nondigit_option): Reset the buffer every time a non-digit option is found or a new argument is started.
* Avoid using an invalid memchr result.Paolo Bonzini2009-12-221-6/+12
| | | | | | | Related to bug 13161. I cannot find a testcase, but it is better to be defensive considering that these bug were found in the past. * src/search.c (EGexecute, Fexecute): Check for memchr return values.
* maint: enable prohibit_have_config_h checkJim Meyering2009-12-043-9/+3
| | | | | | | | | * cfg.mk (local-checks-to-skip): Enable sc_prohibit_have_config_h * lib/regex.c: Remove useless cpp test of HAVE_CONFIG_H. * lib/savedir.c: Likewise. * src/grep.c: Likewise. * src/kwset.c: Likewise. * src/search.c: Likewise.
* maint: enable cast_of_x_alloc_return_value checkJim Meyering2009-12-043-9/+8
| | | | | | | | * cfg.mk (local-checks-to-skip): Enable sc_cast_of_x_alloc_return_value. * .x-sc_cast_of_x_alloc_return_value: * src/dfa.c (CALLOC, MALLOC, REALLOC): Remove casts. * src/dosbuf.c (undossify_input): Likewise. * src/grep.c (print_line_middle, prepend_default_options): Likewise.
* fix "grep -Ff" on CRLF-terminated filesPaolo Bonzini2009-12-041-6/+20
| | | | | * src/search.c (Fcompile) [HAVE_DOS_FILE_CONTENTS]: Recognize \r\n as a line terminator.
* switch to pkg-config for PCRE detectionPaolo Bonzini2009-12-041-0/+1
| | | | | * configure.ac: use pkg-config to detect PCRE * src/Makefile.am (grep_LDADD): link grep with PCRE_LIBS
* maint: enable useless-if-before-free checkJim Meyering2009-12-042-12/+7
| | | | | | | | * cfg.mk (local-checks-to-skip): Enable sc_avoid_if_before_free. * .x-sc_avoid_if_before_free: New file. Exempt regex.c and dfa.c, in case anyone ever tries to merge their contents with other versions. * src/grep.c (print_line_middle, grepdir): Remove useless if-before-free. * src/search.c (IF_BK, EXECUTE_FCT): Likewise.
* maint: enable two checksJim Meyering2009-11-302-3/+3
| | | | | | | | * cfg.mk (local-checks-to-skip): Enable two: sc_prohibit_xalloc_without_use sc_two_space_separator_in_usage * src/grep.c (usage): Conform: use two spaces, not 1. * src/kwset.c (malloc): Define as a function-macro so that the syntax-check rule sees that we are indeed using xmalloc here.
* maint: enable makefile @...@ checkJim Meyering2009-11-301-1/+1
| | | | | | | | * cfg.mk (local-checks-to-skip): Enable sc_makefile_check. * lib/Makefile.am (libgreputils_a_LIBADD): Use $(...), rather than anachronistic @...@ notation. * src/Makefile.am (LDADD): Likewise. * tests/Makefile.am (AWK): Remove definition.
* maint: enable trailing_blank checkJim Meyering2009-11-302-4/+4
| | | | | | | | | | | | | | | | | | | * cfg.mk (local-checks-to-skip): Enable sc_trailing_blank. * AUTHORS: Remove trailing blanks. * COPYING: Likewise. * README: Likewise. * README-alpha: Likewise. * README-boot: Likewise. * THANKS: Likewise. * TODO: Likewise. * src/dfa.c: Likewise. * src/mbsupport.h: Likewise. * tests/backref.sh: Likewise. * tests/file.sh: Likewise. * tests/options.sh: Likewise. * tests/tests: Likewise. * vms/README: Likewise. * vms/make.com: Likewise.
* maint: enable unmarked_diagnostics checkJim Meyering2009-11-301-2/+2
| | | | | | * cfg.mk (local-checks-to-skip): Enable sc_unmarked_diagnostics * src/grep.c (fillbuf): Mark a diagnostic for translation. (reset): Likewise.
* maint: enable require_config_h checksJim Meyering2009-11-302-0/+4
| | | | | | | | | * cfg.mk (local-checks-to-skip): Enable sc_require_config_h and sc_require_config_h_first. * src/dosbuf.c: Include <config.h>. * src/vms_fab.c: Likewise. * .x-sc_require_config_h: New file: list the exceptions. * .x-sc_require_config_h_first: Likewise.
* maint: use gnulib's progname module; enable set_program_name checkJim Meyering2009-11-301-7/+8
| | | | | | | | * bootstrap.conf (gnulib_modules): Add progname. * src/grep.c: Include "progname.h". (program_name): Remove declaration. (main): Call set_program_name. * cfg.mk (local-checks-to-skip): Add sc_program_name.
* build: adapt to the newer closeout module from gnulibJim Meyering2009-11-301-1/+2
| | | | | | * src/grep.c: Include "exitfail.h". (main) [-q]: Set the global variable, exit_failure, rather than calling the now-removed close_stdout_set_file_name function.
* build: adapt to the newer exclude API we now get from gnulibJim Meyering2009-11-301-5/+5
| | | | | * src/grep.c (main): Adapt to newer exclude.c: add EXCLUDE_WILDCARDS as the new "option" argument in calls to add_exclude and add_exclude_file.
* build: get more lib/* files from gnulib, adjust savedirJim Meyering2009-11-301-3/+3
| | | | | | | | | | | | | | * bootstrap.conf (gnulib_modules): Add the following: closeout exclude hard-locale isdir strtoumax. * lib/.gitignore, m4/.gitignore: Update. * lib/closeout.c, lib/closeout.h: Remove. * lib/exclude.c, lib/exclude.h: Remove. * lib/hard-locale.c, lib/hard-locale.h: Remove. * lib/strtoumax.c: Remove. * lib/isdir.c: Remove. * lib/Makefile.am: Remove here, too. * lib/savedir.c: Adapt to new exclude module: s/excluded_filename/excluded_file_name/ and remove 3rd argument.
* replace AC_DOSFILE with gnulib modulesPaolo Bonzini2009-11-262-25/+6
| | | | | | | | * bootstrap.conf: Add binary-io, dirname. * configure.ac: Remove check for setmode, AC_DOSFILE. * m4/dosfile.m4: Remove. * src/grep.c: Adjust for dirname.h. * src/system.h: Adjust for new gnulib modules.
* replace AC_CHECK_* with gnulib modulesPaolo Bonzini2009-11-266-136/+19
| | | | | | | | | | | | | | | | * bootstrap.conf: Add gnulib modules for replacement functions and headers. * configure.ac: Remove macros subsumed by gnulib. * lib/hard-locale.c: Remove guards for headers/functions provided by gnulib. * lib/regex.c: Likewise. * lib/savedir.c: Likewise. * src/dfa.c: Likewise. * src/dfa.h: Do not look at PROTOTYPES. * src/grep.c: Likewise. * src/mbsupport.h: Likewise. * src/system.h: Likewise. * m4/mbstate_t.m4: Remove. * src/getpagesize.h: Remove.
* add gnulib modulesPaolo Bonzini2009-11-261-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bootstrap.conf: Add gnulib modules and build libgreputils.a. * configure.ac: Remove macros subsumed by gnulib. * lib/Makefile.am: Remove files subsumed by gnulib. * lib/alloca.c: Remove. * lib/atexit.c: Remove. * lib/error.c: Remove. * lib/error.h: Remove. * lib/fnmatch.c: Remove. * lib/fnmatch.h: Remove. * lib/getopt.c: Remove. * lib/getopt.h: Remove. * lib/getopt1.c: Remove. * lib/gettext.h: Remove. * lib/malloc.c: Remove. * lib/memchr.c: Remove. * lib/obstack.c: Remove. * lib/obstack.h: Remove. * lib/quotearg.c: Remove. * lib/quotearg.h: Remove. * lib/realloc.c: Remove. * lib/stpcpy.c: Remove. * lib/strtol.c: Remove. * lib/strtoul.c: Remove. * lib/strtoull.c: Remove. * lib/xalloc.h: Remove. * lib/xmalloc.c: Remove. * lib/xstrtol.c: Remove. * lib/xstrtol.h: Remove. * lib/xstrtoumax.c: Remove. * m4/error.m4: Remove. * m4/inttypes_h.m4: Remove. * m4/malloc.m4: Remove. * m4/realloc.m4: Remove. * m4/uintmax_t.m4: Remove. * m4/ulonglong.m4: Remove. * m4/xstrtoumax.m4: Remove. * src/system.h: Remove strerror, sys_nerr, sys_errlist.
* use gettext.hPaolo Bonzini2009-11-202-23/+6
| | | | | | | | | | * lib/Makefile.am: Distribute gettext.h. * lib/closeout.c: Use it. * lib/gettext.h: New. * lib/quotearg.c: Use it. * lib/xmalloc.c: Use it. * src/dfa.c: Use it. * src/system.h: Use it.
* upgrade to external gettext, modernize handling of m4 subdirectoryPaolo Bonzini2009-11-201-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac.in (AM_GNU_GETTEXT_VERSION): Bump to 0.17. (AC_OUTPUT): Remove m4/Makefile creation. * Makefile.am (subdirs): Remove m4 subdirectory. (EXTRA_DIST): Add build-aux/config.rpath. * intl/*: Remove. * m4/Makefile.am: Remove. * m4/codeset.m4: Remove. * m4/glibc.m4: Remove. * m4/glibc21.m4: Remove. * m4/header.m4: Remove. * m4/install.m4: Remove. * m4/isc-posix.m4: Remove. * m4/lcmessage.m4: Remove. * m4/sanity.m4: Remove. * m4/gettext.m4: Upgrade to gettext-0.17. * m4/iconv.m4: Upgrade to gettext-0.17. * m4/lib-ld.m4: New file, from gettext-0.17. * m4/lib-link.m4: New file, from gettext-0.17. * m4/lib-prefix.m4: New file, from gettext-0.17. * m4/nls.m4: New file, from gettext-0.17. * m4/po.m4: New file, from gettext-0.17. * m4/progtest.m4: Upgrade to gettext-0.17. * m4/Makefile.am (EXTRA_DIST): Add the new files. * po/Makefile.in.in: Upgrade to gettext-0.17. * po/Makevars: New. * po/cat-id-tbl.c: New. * src/Makefile.am: Replace @INTLLIBS@ with @LIBINTL@.
* start modernizing autoconf infrastructurePaolo Bonzini2009-11-201-2/+0
| | | | | | | | | | | * configure.ac: Slightly modernize. * Makefile.am: Modernize, use dependencies. * Makefile.am: Modernize, use dependencies. * lib/Makefile.am: Remove ansi2knr. * src/Makefile.am: Remove ansi2knr. * .gitignore: Add INSTALL * build-aux/.gitignore: New.
* move .cvsignore files to .gitignorePaolo Bonzini2009-11-202-6/+3
|
* (usage): one more tweak to the --help output.Karl Berry2009-02-011-1/+1
|
* punctuation in --help messageKarl Berry2009-02-011-1/+1
| | | | * src/grep.c (usage): consistent punctuation.
* mention urls in help msgKarl Berry2009-01-301-0/+5
| | | | * src/grep.c (usage): mention gnu.org/s/grep and gnu.org/gethelp.
* update/add copyright noticesKarl Berry2009-01-3012-7/+96
|
* * lib/savedir.c (isdir): New declaration.Tony Abou-Assaleh2009-01-253-20/+23
| | | | | | | | | | | | | | | | | | | * src/dfa.c (update_mb_len_index): Change argument type to 'char const *'. (match_mb_charset): Cast argument to strncpy. (dfaexec): Add pointer cast. * src/grep.c (parse_grep_colors): Add braces for disambiguation. * src/kwset.c: Include xalloc.h instead of declaring xmalloc manually. * lib/savedir.c (isdir): New declaration. * src/dfa.c (update_mb_len_index): Change argument type to 'char const *'. (match_mb_charset): Cast argument to strncpy. (dfaexec): Add pointer cast. * src/grep.c (parse_grep_colors): Add braces for disambiguation. * src/kwset.c: Include xalloc.h instead of declaring xmalloc manually.
* * tests/foad1.sh: disable tests that fail under cs_CZ.UTF-8.Tony Abou-Assaleh2009-01-211-2/+2
| | | | | | | * tests/fmbtest.sh: likewise * tests/foad1.sh: disable tests that fail under cs_CZ.UTF-8. * tests/fmbtest.sh: likewise
* src/ansi2knr.[1c]: Remove generated files (installed by automake).Tony Abou-Assaleh2008-06-152-714/+0
| | | | | * src/ansi2knr.[1c]: Remove generated files (installed by automake). Thanks to Emanuele Giaquinta for this.
* * src/grep.c: Factor out copyright year in --version. Thanks toTony Abou-Assaleh2008-02-141-4/+4
| | | | | | | | | Karl Berry for this. * src/grep.c: Update copyright years * src/grep.c: Factor out copyright year in --version. Thanks to Karl Berry for this. * src/grep.c: Update copyright years
* * src/grep.c: Update grep copyright yearTony Abou-Assaleh2008-02-101-1/+1
| | | | * src/grep.c: Update grep copyright year
* * README-alpha: more info about CVS codeTony Abou-Assaleh2008-02-101-1/+2
| | | | | | | * README: pointer to README-alpha * README-alpha: more info about CVS code * README: pointer to README-alpha
* * src/dfa.c: Replace a MALLOC and for loop with a CALLOC.Tony Abou-Assaleh2008-02-091-3/+1
| | | | | * src/dfa.c: Replace a MALLOC and for loop with a CALLOC. Thanks to Johan Walles for this. Patch #6288
* * .cvsignore: add configure.acTony Abou-Assaleh2008-02-081-0/+1
| | | | | | | * src/.cvsignore: add .deps * .cvsignore: add configure.ac * src/.cvsignore: add .deps
* * Re-commit changes of 2007-10-07Tony Abou-Assaleh2007-10-101-3/+6
| | | | | | | | | | | | | | * configure.ac.in: update version to 2.6-dev * src/grep.c: update --version message * configure.ac.in: update version to 2.6-dev * src/grep.c: update --version message * src/grep.c: When -h and -H are combined, use the last specified, Bug #15620, Patch #4866 * tests/foad1.sh: add tests for -h and -H * ChangeLog: Add a copyright notice (years taken from commit logs), add a license notice (taken from gnulib ChangeLog) * TODO: update the link to a list of other grep implementations
* Revert changes since grep-2.5.3 release to add a tag to CVS.v2.5.3Tony Abou-Assaleh2007-10-101-2/+0
|
* * src/grep.c: When -h and -H are combined, use the last specified,Tony Abou-Assaleh2007-10-071-0/+2
| | | | | | | | | | | | | | | Bug #15620, Patch #4866 * tests/foad1.sh: add tests for -h and -H * ChangeLog: Add a copyright notice (years taken from commit logs), add a license notice (taken from gnulib ChangeLog) * TODO: update the link to a list of other grep implementations * src/grep.c: When -h and -H are combined, use the last specified, Bug #15620, Patch #4866 * tests/foad1.sh: add tests for -h and -H * ChangeLog: Add a copyright notice (years taken from commit logs), add a license notice (taken from gnulib ChangeLog) * TODO: update the link to a list of other grep implementations
* GPLv2 -> GPLv3Bernhard Rosenkraenzer2007-06-289-9/+9
|
* --exclude-dirBernhard Rosenkraenzer2006-08-181-4/+20
| | | | | * lib/savedir.c, lib/savedir.h, src/grep.c, doc/*: Add --exclude-dir option (patch #5051)
* Remove bogus warningBernhard Rosenkraenzer2006-08-181-6/+0
|
* On 2005-06-21, many changes were made that affected --color,Charles Levert2005-11-171-42/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | --only-matching, and --invert-match. Some of them introduced a misunderstanding between the concepts of matched/non-matched and selected/rejected lines. Furthermore, a few bugs with -v sneaked in stemming from this. This set of changes aims to rectify most of this situation. Some GREP_COLORS capabilities are also added as a result of the clarification. (Further issues with -v/-o/-C feature interaction still remain to be sorted out.) * src/grep.c: Rename/add global variables, macros, and capabilities: SEP_CHAR_MATCH --> SEP_CHAR_SELECTED SEP_CHAR_CONTEXT --> SEP_CHAR_REJECTED SEP_STR_CHUNK --> SEP_STR_GROUP grep_color --> selected_match_color + context_match_color mlines_color --> selected_line_color context_color --> context_line_color "ml" --> "sl" "mt" --> "mt" = "ms" + "mc" --> "rv" (reverse "sl"/"cx" when -v) * src/grep.c (color_cap_mt_fct, color_cap_rv_fct): New functions. * src/grep.c (print_line_tail): Renamed color argument to line_color. * src/grep.c (print_line_middle, prline): Revert part of the logic to a pre-2005-06-21 one so that lines with matches have their matched parts properly handled again ("m?" colors or --only-matching), whether or not -v is specified. Whole line colors ("sl", "cx") follow a selected / rejected(context) logic, as opposed to a matched / non-matched one (unless "rv"). Matched text colors ("ms", "mc") always follow a selected / rejected(context) logic, regardless of "rv", because only matched lines use them anyway. pr_line_middle() now takes additional line_color and match_color arguments computed by prline() prior to calling that function. The old logic was a buggy hybrid matched / rejected(context) one. * src/grep.c (prpending, prtext, grepfile): Renamed macro invocations. * src/grep.c (parse_grep_colors): Update top comment. * src/grep.c (main): GREP_COLOR (singular) now sets both selected_match_color and context_match_color.
* * src/search.c (Pcompile): Clarify message for the -P optionCharles Levert2005-11-161-1/+1
| | | | | | not being supported so that users don't assume it's a run-time problem, but know that it's a compile-time configuration choice. Based on an idea by: Benno Schulenberg <benno@nietvergeten.nl>.
* * src/grep.c (parse_grep_colors, main): Replace all uses ofCharles Levert2005-11-111-16/+11
| | | | | | fprintf(stderr, _("%s: foo\n"), program_name, ...) with error(0, 0, _("foo"), ...) for uniformization and simplification of warning messages that will be up for localization. (My bad.)
* * src/search.c (Pcompile): Abort in error if -P and multiple patternsCharles Levert2005-11-111-1/+3
| | | | | | | are specified, with an error message explaining the situation. Fixing this won't be simple; the '\n' characters separating the patterns cannot just be replaced by '|' to create an alternation as back-references are assumed to be local to each individual pattern.
* The introduction of the --only-matching and --color GNU extensionsCharles Levert2005-11-103-94/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).