summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* build: fix compilation error on MSVC 9 to due Pexecute() declarationBruno Haible2011-11-121-9/+4
| | | | | | * src/pcresearch.c (WITHOUT_PCRE_NORETURN): Remove macro. (Pexecute): Replace abort() call with code that does not trigger GCC warnings.
* dfa: don't mishandle high-bit bytes in a regexp with signed-charEli Zaretskii2011-10-041-2/+7
| | | | | | | | | | | This appears to arise only on systems for which "char" is signed. * src/dfa.c (FETCH_WC, FETCH): Produce an unsigned value, rather than a sign-extended one. Fixes a bug on MS-Windows with compiling patterns that include characters with the 8-th bit set. (to_uchar): Define. From coreutils. Reported by David Millis <tvtronix@yahoo.com>. See http://thread.gmane.org/gmane.comp.gnu.grep.bugs/3893 * NEWS (Bug fixes): Mention it.
* maint: dfa: simplify multi-byte-related conditionalsJim Meyering2011-09-164-21/+20
| | | | | | | | | | | | | | * src/dfa.c (setbit_case_fold_c, parse_bracket_exp, lex): (addtok_mb, dfaparse): Change each "MBS_SUPPORT && MB_CUR_MAX > 1" test to just "MB_CUR_MAX > 1". * src/dfasearch.c (kwsincr_case, EGexecute): Likewise. * src/kwsearch.c (Fcompile, Fexecute): Likewise. * src/searchutils.c (kwsinit): Likewise. * src/dfa.c (parse_bracket_exp): Convert "if (!MBS_SUPPORT || MB_CUR_MAX == 1)" to "if (MB_CUR_MAX == 1)" and do this: - assert(!MBS_SUPPORT || MB_CUR_MAX == 1); + assert(MB_CUR_MAX == 1);
* maint: dfa: simplify several expressionsJim Meyering2011-09-161-10/+9
| | | | | | | | * src/dfa.c (dfainit): Set d->mb_cur_max unconditionally, now that MB_CUR_MAX is always usable. With that, simplify all "MBS_SUPPORT && d->mb_cur_max > 1" to simply "d->mb_cur_max > 1". (dfastate, dfaexec, dfainit, dfafree): Simplify, removing each now-unnecessary "MBS_SUPPORT &&".
* maint: dfa: avoid in-function "#if MBS_SUPPORT" testsJim Meyering2011-09-161-10/+6
| | | | | | * src/dfa.c (setbit_case_fold_c): Remove "#if MBS_SUPPORT" in favor of simple "if (MBS_SUPPORT ...". (dfaexec, addtok): Likewise.
* maint: ensure that MB_CUR_MAX is defined even when !MBS_SUPPORTJim Meyering2011-09-161-0/+5
| | | | * src/mbsupport.h [!MBS_SUPPORT] (MB_CUR_MAX): Define to 1.
* build: fix compilation failure when MBS_SUPPORT is 0Jim Meyering2011-09-161-6/+6
| | | | | | | * src/dfa.c (add_utf8_anychar): Always compile this function, but when MBS_SUPPORT is 0, give it an empty body. (prepare_wc_buf): Likewise. [! MBS_SUPPORT] (setbit_wc): Define to always abort.
* maint: dfa: simplify dfaoptimizeJim Meyering2011-09-161-22/+18
| | | | | | * src/dfa.c (dfaoptimize): Simplify. (dfacomp): Remove now-redundant "if (MBS_SUPPORT)" guard, since dfaoptimize does nothing if !MBS_SUPPORT.
* maint: dfa: remove some #if MBS_SUPPORT guardsJim Meyering2011-09-161-11/+6
| | | | | * src/dfa.c: Replace a few "#if MBS_SUPPORT" directives with "if (MBS_SUPPORT)". Remove some altogether.
* maint: dfa: convert #if-MBS_SUPPORT (dfastate)Jim Meyering2011-09-161-5/+3
| | | | * src/dfa.c (dfastate): Use regular "if", not #if MBS_SUPPORT.
* maint: dfa: convert #if-MBS_SUPPORT (dfastate)Jim Meyering2011-09-161-10/+5
| | | | * src/dfa.c (dfastate): Use regular "if", not #if MBS_SUPPORT.
* maint: dfa: convert #if-MBS_SUPPORT (state_index)Jim Meyering2011-09-161-4/+5
| | | | * src/dfa.c (state_index): Use regular "if", not #if MBS_SUPPORT.
* maint: dfa: convert #if-MBS_SUPPORT (dfaparse)Jim Meyering2011-09-161-3/+1
| | | | * src/dfa.c (dfaparse): Use regular "if", not #if MBS_SUPPORT.'
* maint: dfa: convert #if-MBS_SUPPORT (copytoks)Jim Meyering2011-09-161-14/+8
| | | | * src/dfa.c (copytoks): Use regular "if", not #if MBS_SUPPORT.'
* maint: dfa: convert #if-MBS_SUPPORT (lex)Jim Meyering2011-09-161-11/+4
| | | | * src/dfa.c (lex): Use regular "if", not #if MBS_SUPPORT.'
* maint: dfa: convert #if-MBS_SUPPORT (parse_bracket_exp)Jim Meyering2011-09-161-3/+1
| | | | * src/dfa.c (parse_bracket_exp): Use regular "if", not #if MBS_SUPPORT.
* maint: dfa: convert #if-MBS_SUPPORT (parse_bracket_exp)Jim Meyering2011-09-161-20/+19
| | | | * src/dfa.c (parse_bracket_exp): Use regular "if", not #if MBS_SUPPORT.
* maint: dfa: convert #if-MBS_SUPPORT (parse_bracket_exp)Jim Meyering2011-09-161-6/+2
| | | | * src/dfa.c (parse_bracket_exp): Use regular "if", not #if MBS_SUPPORT.
* maint: dfa: convert #if-MBS_SUPPORT (dfaexec)Jim Meyering2011-09-161-3/+1
| | | | * src/dfa.c (dfaexec): Use regular "if", not #if MBS_SUPPORT.
* maint: dfa: convert #if-MBS_SUPPORT (dfaexec)Jim Meyering2011-09-161-19/+13
| | | | | * src/dfa.c (dfaexec): Use regular "if", not #if MBS_SUPPORT. Also add curly braces around multi-line if/else blocks.
* maint: dfa: remove #if-MBS_SUPPORT (free_mbdata)Jim Meyering2011-09-161-2/+0
| | | | * src/dfa.c (free_mbdata): Remove the #if guard altogether.
* maint: dfa: convert #if-MBS_SUPPORT (dfaoptimize, dfacomp)Jim Meyering2011-09-161-22/+22
| | | | | * src/dfa.c (dfaoptimize, dfacomp): Use regular "if", not #if MBS_SUPPORT.
* maint: dfa: convert #if-MBS_SUPPORT (dfafree)Jim Meyering2011-09-161-6/+3
| | | | * src/dfa.c (dfafree): Use regular "if", not #if MBS_SUPPORT.
* maint: dfa: convert #if-MBS_SUPPORT (parse_bracket_exp, part1)Jim Meyering2011-09-161-9/+3
| | | | * src/dfa.c (parse_bracket_exp): Remove in-function #if MBS_SUPPORT.
* maint: remove #if-MBS_SUPPORT declaration guardsJim Meyering2011-09-161-2/+0
| | | | * src/search.h: Don't bother to #if-out declarations.
* maint: convert #if-MBS_SUPPORT (EGexecute)Jim Meyering2011-09-161-5/+4
| | | | * src/dfasearch.c (EGexecute): Remove in-function #if MBS_SUPPORT.
* maint: convert #if-MBS_SUPPORT (kwsincr_case)Jim Meyering2011-09-161-10/+4
| | | | | * src/dfasearch.c (kwsincr_case): Remove in-function #if MBS_SUPPORT. Move decl's down.
* maint: convert #if-MBS_SUPPORT (Fcompile, etc.)Jim Meyering2011-09-161-17/+12
| | | | | * src/kwsearch.c (Fcompile, Fexecute): Remove in-function #if MBS_SUPPORT. (Fcompile): Rearrange some declarations. No semantic change.
* maint: convert #if-MBS_SUPPORT (kwsinit)Jim Meyering2011-09-161-5/+1
| | | | * src/searchutils.c (kwsinit): Remove in-function #if MBS_SUPPORT.
* maint: dfa: remove case-guarding #if-MBS_SUPPORTJim Meyering2011-09-161-2/+0
| | | | * src/dfa.c [DEBUG] (prtok): Remove now-useless #if-MBS_SUPPORT.
* maint: remove #if MBS_SUPPORT around member declarationJim Meyering2011-09-151-2/+0
| | | | * src/dfa.c (dfastate): Don't #ifdef-out "mbps" position_set member.
* maint: dfa: remove #if MBS_SUPPORT around struct definitionJim Meyering2011-09-151-2/+0
| | | | * src/dfa.c (struct mb_char_classes): Don't #ifdef-out declarations.
* build: avoid compilation failure when building without PCRE supportJim Meyering2011-09-151-1/+1
| | | | | | * src/pcresearch.c [!HAVE_LIBPCRE] (WITHOUT_PCRE_NORETURN): Define to _Noreturn, not obsoleted-by-gnulib _GL_ATTRIBUTE_NORETURN. Reported by Eric Blake.
* maint: dfa: improve commentsJim Meyering2011-09-151-10/+7
| | | | * src/dfa.c (match_mb_charset, match_anychar): Improve comments.
* maint: correct indentationJim Meyering2011-09-141-7/+9
| | | | | * src/dfa.c (dfaexec): Reposition curly braces to match indentation style. Remove useless comment.
* maint: move declaration "down" to inner scope where it is usedJim Meyering2011-09-141-2/+2
| | | | * src/dfa.c (dfaexec): Move decl of local down into scope where used.
* doc: use "file name" consistently in grep's --help outputJim Meyering2011-09-071-3/+3
| | | | | | | | * src/main.c (usage): Use "file name", not "filename" in descriptions of --with-filename (-H), --no-filename (-h) and --label=LABEL. Suggested by Sequoia McDowell. bug: requires ru_RU.KOI8-R". [bug introduced in grep-2.9]
* maint: clean up and plug a leak-on-OOMJim Meyering2011-08-201-28/+20
| | | | | | | | | | * src/dfa.c (icatalloc): Clean up; use xrealloc in place of malloc and realloc; remove conditionals that are unnecessary, now that failed allocation results in exit. (enlist): Use xrealloc in place of realloc; remove conditional. (comsubs): Avoid leak upon failed enlist call. (dfamust): Use xmalloc in place of malloc. Remove conditionals, now that icpyalloc and icatalloc never return NULL.
* maint: use x2nrealloc, not xreallocJim Meyering2011-08-201-1/+1
| | | | * src/main.c (main): Use x2nrealloc, not xrealloc
* exit 2 (rather than infloop) when an input file is also on stdoutJim Meyering2011-07-242-1/+67
| | | | | | | | | | | | | | | | | This avoids a potential "infinite" disk-filling loop. Reported in http://savannah.gnu.org/patch/?5316 and http://savannah.gnu.org/bugs/?17457. * src/main.c: Include "quote.h". (out_stat): New global. (grepfile): Compare each regular file's dev/ino/etc. with those from the file on stdout (if it too is regular). (main): Set out_stat, if stdout is a regular file. * src/system.h: Include "same-inode.h". (same_file_attributes): Define. From diffutils. (SAME_REGULAR_FILE): Define. * bootstrap.conf (gnulib_modules): Use quote, not quotearg. Use same-inode. * NEWS (Bug fixes): Mention it.
* dfa: remove unnecessary inclusion of verify.hJim Meyering2011-07-121-1/+0
| | | | * src/dfa.c: Don't include "verify.h".
* dfa: simplify use of *ALLOC macrosJim Meyering2011-07-121-51/+68
| | | | | * src/dfa.c (XNMALLOC, XCALLOC): Redefine without outer cast-to-(t *). (CALLOC, MALLOC, REALLOC): Remove type "t" parameter and adjust callers.
* dfa: change semantics of REALLOC_IF_NECESSARY's 3rd parameterJim Meyering2011-07-121-9/+10
| | | | | | | | * src/dfa.c (REALLOC_IF_NECESSARY): Change meaning of 3rd param, from "maximum index" to 1 greater than that: the required number of *P-sized elements. Note that only some of the uses of REALLOC_IF_NECESSARY needed to be adjusted, the others had already required an extra element.
* dfa: rename REALLOC_IF_NECESSARY param/local for clarityJim Meyering2011-07-121-5/+5
| | | | | * src/dfa.c (REALLOC_IF_NECESSARY): Rename nalloc and new_nalloc to n_alloc and new_n_alloc.
* dfa: prepare for a semantic change in REALLOC_IF_NECESSARYJim Meyering2011-07-121-20/+19
| | | | | * src/dfa.c (REALLOC_IF_NECESSARY): Remove "t" (type) parameter. Use (*p) instead. Adjust all callers.
* dfa: add braces to REALLOC_IF_NECESSARY definitionJim Meyering2011-07-121-8/+10
| | | | | * src/dfa.c (REALLOC_IF_NECESSARY): Add curly braces; use TABs to right-indent.
* dfa: fix the root cause of the heap overrunJim Meyering2011-06-281-5/+5
| | | | | | | | | | | | | | | | | | dfa's "insert" function was supposed to be maintaining the position list sorted on *decreasing* index, but since the 2009-12-09 "Speed up insert" commit, 62458291, it was using code that assumed the data were sorted on *increasing* index. As such, sometimes it would no longer merge constraints (not finding a match) and would append entries that normally would have matched and been merged. Those erroneous append operations resulted in the heap overrun fixed by 2011-06-17 commit 0b91d692 by doubling the array size. * src/dfa.c (insert): Fix the comparison. (dfaanalyze): Now that that's fixed, revert commit 0b91d692, allocating space for only d->nleaves entries, not double that. As far as I can tell, this change has no effect other than decreased memory usage, although it may improve performance slightly, since the resulting list of positions is half as long as it used to be.
* dfa: use memcpy to copy position_setsPaolo Bonzini2011-06-281-4/+1
| | | | * src/dfa.c (copy): Use memcpy.
* dfa: use copyset to copy charclassesPaolo Bonzini2011-06-281-1/+1
| | | | * src/dfa.c (add_utf8_anychar): Change memcpy to copyset.
* build: avoid a warning when building with --disable-perl-regexp...Jim Meyering2011-06-211-2/+8
| | | | | | | and --enable-gcc-warnings. * src/pcresearch.c (WITHOUT_PCRE_NORETURN): Define. Remove the unreachable return statement. Reported by Eric Blake.