.
* src/grep.c (GAcompile, PAcompile): New functions.
(const): Use them.
2014-01-10 Pádraig Brady
tests: remove superfluous uses of printf
* tests/turkish-eyes: Remove unnecessary uses of printf.
2014-01-09 Jim Meyering
grep: make --ignore-case (-i) faster (sometimes 10x) in multibyte locales
These days, nearly everyone uses a multibyte locale, and grep is often
used with the --ignore-case (-i) option, but that option imposes a very
high cost in order to handle some unusual cases in just a few multibyte
locales. This change gets most of the performance of using LC_ALL=C
without eliminating the ability to search for multibyte strings.
With the following example, I see an 11x speed-up with a 2.3GHz i7:
Generate a 10M-line file, with each line consisting of 40 'j's:
yes jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj | head -10000000 > k
Time searching it for the simple/noexistent string "foobar",
first with this patch (best-of-5 trials):
LC_ALL=en_US.UTF-8 env time src/grep -i foobar k
1.10 real 1.03 user 0.07 sys
Back out that commit (temporarily), recompile, and rerun the experiment:
git log -1 -p|patch -R -p1; make
LC_ALL=en_US.UTF-8 env time src/grep -i foobar k
12.50 real 12.41 user 0.08 sys
The trick is to realize that for some search strings, it is easy
to convert to an equivalent one that is handled much more efficiently.
E.g., convert this command:
grep -i foobar k
to this:
grep '[fF][oO][oO][bB][aA][rR]' k
That allows the matcher to search in buffer mode, rather than having to
extract/case-convert/search each line separately. Currently, we perform
this conversion only when search strings contain neither '\' nor '['.
See the comments for more detail.
* src/main.c (trivial_case_ignore): New function.
(main): When possible, transform the regexp so we can drop the -i.
* tests/turkish-eyes: New file.
* tests/Makefile.am (TESTS): Use it.
* NEWS (Improvements): Mention it.
2014-01-07 Paul Eggert
tests: port Solaris 10 /bin/sh patch back to GNU/Linux
Problem reported by Jim Meyering.
* tests/bre, tests/ere, tests/spencer1-locale:
Prefer re_shell, not re_shell_.
* tests/init.sh (re_shell): New var, which is exported instead of
re_shell_.
Port to Solaris 10 /bin/sh.
Problem reported by Dagobert Michelsen in .
* tests/bre, tests/ere, tests/spencer1-locale:
Prefer re_shell_ to SHELL, if re_shell_ is set.
* tests/init.sh (re_shell_): Export if it's used.
2014-01-01 Jim Meyering
maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
version 2.16
* NEWS: Record release date.
gnulib: update to latest, for maint.mk fix
maint: update copyright dates for 2014
Do that by running "make update-copyright".
gnulib: update to latest
2013-12-31 Jim Meyering
pcre: use PCRE_NO_UTF8_CHECK properly
In order to obtain the behavior we want, i.e., to disable
error-on-invalid-UTF-in-input, apply this PCRE option in
pcre_exec, not when compiling.
* src/pcresearch.c (Pexecute): Use PCRE_NO_UTF8_CHECK here, ...
(Pcompile): ...rather than here.
* tests/pcre-invalid-utf8-input: Adjust test case to test for this.
2013-12-26 Jim Meyering
maint: fix inconsistent spacing in expression
* src/main.c (prline): Fix inconsistent spacing in expression:
s/ / /.
2013-12-26 behoffski
maint: fix a garbled comment
* src/dfa.c (XNMALLOC, etc.): Fix garbled comment wording.
2013-12-23 Jim Meyering
maint: fix/improve a comment
* src/main.c (prline): Replace untrue FIXME comment with one
telling how the hard-to-reach code can be exercised.
2013-12-21 Santiago Ruano Rincón
pcre: tell grep -P to relax its stance on invalid multibyte chars
Do not exit-2 for invalid UTF-8 characters. Just prior to this
change, this command would match no lines and fail like this:
$ printf 'j\x82\nj\n'|LC_ALL=en_US.UTF-8 grep -P j|cat -A; echo $?
grep: invalid UTF-8 byte sequence in input
2
After this change, the same command matches both lines, and succeeds:
jM-^B$
j$
0
* src/pcresearch.c (Pcompile): Use PCRE_NO_UTF8_CHECK, too, and
add a comment.
* tests/pcre-utf8: Add a test and a comment.
This change did not work with Debian unstable pcre-8.31-2
or with some 8.33 and 8.34-based versions, but does work with
Fedora 20's 8.33 and with a built-from-latest source library.
Based on a patch by Santiago Ruano Rincón.
See http://bugs.gnu.org/15758/
2013-12-21 Jim Meyering
tests: avoid FP failure due to exhausted memory
* tests/long-line-vs-2GiB-read: Don't declare the test "failed"
when running out of memory. In that case, skip it.
2013-12-18 Jim Meyering
maint: add comments and split some long lines
* src/main.c (do_execute): Add a comment.
Split some lines longer than 80 bytes.
pcre: avoid a nominal leak
* src/pcresearch.c (Pcompile)[HAVE_LIBPCRE && !PCRE_STUDY_JIT_COMPILE]:
We would leak "re" if built with HAVE_LIBPCRE but without
PCRE_STUDY_JIT_COMPILE. Move the free out one level.
maint: indent cpp directives to reflect nesting
* src/pcresearch.c: Insert spaces after a few "#", to indent
cpp directives to reflect their nesting.
grep: handle lines longer than INT_MAX on more systems
When trying to exercize some long-line-handling code, I ran these
commands:
$ dd bs=1 seek=2G of=big < /dev/null; grep -l x big; echo $?
grep: big: Invalid argument
2
grep should not have issued that diagnostic, and it should
have exited with status 1, not 2. What happened?
grep read the 2GiB of NULs, doubled its buffer size,
copied the 2GiB into the new 4GiB buffer, and proceeded
to call "read" with a byte-count argument of 2^32.
On at least Darwin 12.5.0, that makes read fail with EINVAL.
The solution is to use gnulib's safe_read wrapper.
* src/main.c: Include "safe-read.h"
(fillbuf): Use safe_read, rather than bare read. The latter
cannot handle a read size of 2^32 on some systems.
* bootstrap.conf (gnulib_modules): Add safe-read.
* tests/long-line-vs-2GiB-read: New file.
* tests/Makefile.am (TESTS): Add it.
* NEWS (Bug fixes): Mention it.
2013-11-25 Jim Meyering
tests: port to non-GNU sed
* tests/multibyte-white-space (utf8_space_characters): The generation
of test inputs relied on GNU sed's interpretation of \<, but that is
not portable, and caused spurious test failures. Adjust the sed regexp
to work on all versions.
Reported by Karl Dubost in http://bugs.gnu.org/15953.
2013-11-22 Jim Meyering
maint: minor cleanup: xmalloc+strcpy -> xmemdup
* src/main.c (main): Replace an xmalloc+strcpy combination
with an equivalent use of xmemdup.
2013-11-21 Jim Meyering
Paul Eggert
dfa: avoid undefined behavior of "1 << 31"
* src/dfa.c (charclass): Change type from "int" to "unsigned int".
(tstbit): Rather than shifting "1" left to form a mask, shift the
LHS bits the right and use "1" as the mask. Also, return bool, rather
than "int".
(setbit, clrbit, dfastate): Don't shift "1" (aka (int)1) left by 31 bits.
Instead, use "1U" as the operand, to avoid undefined behavior.
Spotted by gcc's new -fsanitize=undefined.
2013-11-02 Jim Meyering
grep: fix regression with -P vs. invalid UTF-8 input
* src/pcresearch.c (Pexecute): Don't abort upon unexpected
PCRE-specific error code. Explicitly handle PCRE_ERROR_BADUTF8,
and change the default to print a diagnostic including the unhandled
integer PCRE error code and exit with status 2.
* tests/pcre-invalid-utf8-input: New file.
* tests/Makefile.am (TESTS): Add it.
* NEWS (Bug fixes): Mention it.
* THANKS: Update.
Reported by Dave Reisner in http://bugs.gnu.org/15758.
grep: fix regression involving \s and \S
Commit v2.14-40-g01ec90b made \s and \S work with multi-byte
characters, but it made it so any use like \s*, \s+, \s?, \s{3}
would malfunction in a multi-byte locale.
* src/dfa.c (lex): Also reset laststart.
* tests/backslash-s-and-repetition-operators: New file.
* tests/Makefile.am (TESTS): Add it.
* NEWS (Bug fixes): Mention it.
* THANKS: Update.
Reported by Mirraz Mirraz in http://bugs.gnu.org/15773.
2013-11-01 Jim Meyering
maint: NEWS: document a release-related bug fix
* NEWS (Bug fixes): Add an entry for a fix pulled from gnulib.
2013-10-26 Jim Meyering
build: update gnulib submodule to latest
This pulls in a gnulib fix for maint.mk that ensures the procedure
described in README-release actually does what we want. Before this
change, that procedure resulted in a grep-2.15 tarball that would
lead to a grep binary whose --version- reported version number was
2.14.51... rather than the expected 2.15.
maint: avoid automake deprecation warning re ACLOCAL_AMFLAGS
* Makefile.am (ACLOCAL_AMFLAGS): Don't use this deprecated variable.
* configure.ac (AC_CONFIG_MACRO_DIRS): Use this instead.
(AUTOMAKE_OPTIONS): Require automake-1.12.
maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
version 2.15
* NEWS: Record release date.
2013-10-25 Paul Eggert
build: port to AIX
Problem reported by Pavel Kharitonov in .
* src/Makefile.am (LDADD): Add $(LIBTHREAD).
build: avoid duplicate -funit-at-a-time etc. options
* configure.ac (WERROR_CFLAGS): Don't add -fdiagnostics-show-option
and -funit-at-a-time, as Gnulib does that for us now, and we're
merely piling on duplicats.
2013-10-24 Jim Meyering
tests: port more tests to bourne shells with hex-challenged printf
* tests/pcre-utf8: Convert the hex \xHH literals for the euro symbol
to octal \OOO.
* tests/turkish-I: Likewise for "I with dot".
* tests/turkish-I-without-dot: Likewise for another Turkish I: U+0131.
maint: clean up an ugly 'while' condition
* src/main.c (get_nondigit_option): Separate a slightly baroque
"while" expression into two separate statements, both inside the loop.
2013-10-23 Jim Meyering
tests: port to bourne shells whose printf doesn't grok hex
Use octal escapes, not hex, in printf(1) format strings,
and in one case, use $AWK's printf so we can continue
to use the table of hex values.
* tests/char-class-multibyte: Use printf octal escapes, not hex,
for portability to shells like dash and Solaris 10's /bin/sh.
* tests/backslash-s-vs-invalid-multitype: Likewise.
* tests/surrogate-pair: Likewise.
* tests/unibyte-bracket-expr: Count in decimal and convert to octal.
* tests/multibyte-white-space (hex_printf): New function.
Use it in place of printf so we can retain the table of hex digits
without hitting the limitation of some bourne shells.
Reported by Paul Eggert in http://bugs.gnu.org/15690#11
2013-10-21 Jim Meyering
gnulib: update to latest
maint: remove now-unused wcscoll module
* bootstrap.conf (gnulib_modules): Remove wcscoll; no longer used.
2013-10-20 Paul Eggert
build: avoid chatter from Automake 1.14
* configure.ac (AM_INIT_AUTOMAKE): Add subdir-objects.
build: port shell pattern to Solaris 10
* configure.ac: Don't use unquoted '^' in a pattern, as this
breaks 'configure' on Solaris 10, whose /bin/sh complains about it,
which causes 'configure' to exit even before it finds a decent shell.
Unix 7th edition shell accepted '^' as an alias for '|'.
build: port to platforms that predefine _FORTIFY_SOURCE
Problem reported by Brenton Hoff (Bug#15663).
* configure.ac (_FORTIFY_SOURCE): Don't define if already defined.
This is what Emacs does.
2013-10-20 Jim Meyering
build: update gnulib submodule to latest
2013-10-19 Jim Meyering
tests: extend the multibyte-white-space test
* tests/multibyte-white-space (utf8_space_characters): Add more
single-byte whitespace characters. Align RHS hex values and
make the sed substitution less rigid, to accommodate.
Also, ensure that grep '\S' exits with status 1.
maint: update bootstrap to latest from gnulib
* bootstrap: Update from gnulib.
maint: fix typo in NEWS
* NEWS: Fix/improve example commands in most recent entry.
The LC_ALL envvar setting goes before grep, not before printf.
Don't reference src/ in the second example command, and do specify
the locale.
2013-10-09 Jim Meyering
tests: add a test for better coverage of some tricky code
* tests/spencer1.tests: Add a non-range bracket expression representing the
same regexp, to cover the alternate code path, the one that does not require
a regcomp/exec call to interpret the regexp.
2013-10-01 Jim Meyering
tests: ensure neither \s nor \S matches an invalid multibyte character
* tests/backslash-S-vs-invalid-multitype: New file.
Prompted by the bug report from Roman at
http://savannah.gnu.org/bugs/?40009
* tests/Makefile.am (TESTS): Add it.
dfa: fix \s and \S to work for multibyte
* src/dfa.c (lex): In multibyte mode, we can't treat \s and \S as we do
in single-byte mode. Map them to [[:space:]] and [^[:space:]] respectively,
to make the DFA matcher use the regex-matcher for this term.
* tests/multibyte-white-space: New file. Test for the bug.
* tests/Makefile.am (TESTS): Add it.
This bug was introduced with the addition of DFA support
for \s and \S in commit v2.5.4-112-gf979ca0.
2013-09-30 Jim Meyering
maint: change all references: s/POSIX\.2/POSIX/
There is no longer any point in referring to POSIX.N.
POSIX is sufficient.
* doc/grep.in.1: As above.
* src/main.c (main): Likewise.
* tests/file: Likewise.
* tests/options: Likewise.
* ChangeLog: Likewise.
* NEWS: Likewise.
* cfg.mk: Update, to match changed NEWS.
Inspired by Glenn Golden's suggestion in http://bugs.gnu.org/15486
2013-09-22 Jim Meyering
dfa: remove dead disjunct
* src/dfa.c (parse_bracket_exp): Remove dead disjunct.
At that point, we know MB_CUR_MAX <= 1, so the test,
MB_CUR_MAX > 1 && ... is always false. Remove the disjunct.
maint: dfa: improve comments and formatting
* src/dfa.c (add_utf8_anychar): Correct wording/alignment of a comment.
(dfaexec): Add curly braces around multi-line while statement within
a "then" block.
(ANYCHAR): Clarify comment: "." does not match an invalid UTF8 character.
(parse_bracket_exp) Improve comment.
2013-09-08 Jim Meyering
dfa: appease a static analyzer, and save 95 stack bytes
* src/dfa.c (MAX_BRACKET_STRING_LEN): Rename from BRACKET_BUFFER_SIZE
and decrease from 128 to 32.
(parse_bracket_exp): Add one byte more than MAX_BRACKET_STRING_LEN
to the length of "str" buffer, to avoid appearance that we may store
the trailing NUL beyond the end of buffer. A string of length 32
or greater is rejected by earlier processing, so would never reach
this code. Addresses http://bugs.gnu.org/15307
2013-09-01 Corinna Vinschen
fix Cygwin UTF-16 surrogate-pair handling with -i
grep -i would segfault on systems using UTF-16-based wchar_t (Cygwin)
when converting an input string containing certain 4-byte UTF-8
sequences to lower case. The conversions to wchar_t and back to
a UTF-8 multibyte string did not take surrogate pairs into account.
* src/searchutils.c (mbtolower) [__CYGWIN__]: Detect and handle
surrogate pairs when converting.
* NEWS (Bug fixes): Mention it.
* tests/surrogate-pair: New test.
* tests/Makefile.am (TESTS): Add it.
Reported by: Jim Burwell
2013-08-19 Paul Eggert
doc: mention how to use the latest gnulib
* README-hacking: Steal some text from coreutils/README-hacking.
2013-08-10 Jim Meyering
build: update gnulib-related code
* gnulib: Update submodule to latest.
* bootstrap: Update from gnulib.
* gl/lib/regex_internal.h.diff: Update to reflect gnulib changes.
* bootstrap.conf: Partial sync from coreutils.
2013-08-09 Jim Meyering
tests: simplify and factor newest test
* tests/char-class-multibyte2: Simplify file names.
Factor out $e_acute, so that the grep argument representation
is ascii (though the value is still UTF8).
doc: NEWS: mention the DFA segfault fix
* NEWS (Bug fixes): List the DFA segfault fix.
2013-07-05 Paul Eggert
Redo comments and white space to better approach GNU style.
2013-07-05 Paolo Bonzini
tests: add testcase for previous change
* tests/Makefile.am (TESTS): add char-class-multibyte2.
* tests/char-class-multibyte2: New file.
2013-07-05 Mike Haertel
dfa: fix multibyte character in brackets with repetition
Let FOO stand for any multibyte (e.g. CJK character) in the regexp.
It turns out the following much simpler regexp:
([^.]*[FOO]){1,2}
is sufficient to cause the crash.
In the first step of its parsing, DFA transforms regexp from human
readable syntax into reverse-polish form. For regexps of the form a{m,n}
repeat counts, it simply builds repeated copies of the representation
of a, with appropriate inserted CAT and QMARK operators. For the above
example with a regexp of the form a{1,2} it would build:
QMARK
CAT
When building repeated copies of RPN representations, additional
copies of the RPN representations are made by calling a function
copytoks() with arguments consisting of the start position and
length of the original copy.
The problem is that the current code for copytoks() is simply
incorrect. It operates by calling addtok() for each individual
token in the source range being copied. But, in the particular
case that the token being added is MBCSET, addtok():
(1) incorrectly assumes that the character set being added to be added
is the one most (addtok has no argument to indicate which cset is
being added, so it just uses the latest one)
(2) attempts to do some token sequence expansion into more primitive
operators so things like [FOO] are matched efficiently.
Both of these assumptions are incorrect in the case that addtok()
is being called from copytoks(): (1) is simply not true, and
(2) is redundant--the expansion has already been done token sequence
being copied, so there is no need to do the expansion again.
The correct function to add exactly one token, without further expansion,
is addtok_mb(). So here is my proposed fix, which is that copytoks()
should never call addtok(), but instead directly call addtok_mb()
(which is what addtok() eventually calls).
* src/dfa.c (copytoks): Rewrite using addtok_mb directly.
2013-05-28 Jim Meyering
maint: align backslashes consistently
* tests/Makefile.am: Most backslashes were aligned with TABs,
so adjust the few that used spaces to conform.
grep -F: avoid an infinite loop with invalid multi-byte search string
* src/kwsearch.c (Fexecute): Avoid an infinite loop when processing
a fixed (-F) multibyte search string that is an invalid byte sequence
in the current locale and that matches the bytes of the input twice
on a line. Reported by Daisuke GOTO in
http://thread.gmane.org/gmane.comp.gnu.grep.bugs/4773
* tests/invalid-multibyte-infloop: New test.
* tests/Makefile.am (TESTS): Add it.
* NEWS (Bug fixes): Mention it.
2013-04-18 Paul Eggert
* cfg.mk (old_NEWS_hash): Update.
doc: document EREs like a{,10}
Problem reported by Eric Blake in
.
* NEWS: Document the bug fix.
* doc/grep.in.1: Restore documentation for this feature, but mention
that it is a GNU extension.
* doc/grep.texi (Fundamental Structure): Mention that this feature
is a GNU extension.
2013-04-02 Paul Eggert
build: make dfa.c closer to Gawk's
* src/dfa.c: Include , not .
stddef.h is smaller and is all we need and is portable nowadays.
Include and only if MBS_SUPPORT.
2013-01-15 Paul Eggert
grep: make dfa.h standalone
Problem reported by Aharon Robbins in
.
* src/dfa.c: Include dfa.h first, so that it's tested standalone.
No need to include , since we are in charge of dfa.h and
know that it includes .
* src/dfa.h: Include and , so that it's standalone.
2013-01-11 Stefano Lattarini
build: update gettext version to 0.18.2
* configure.ac (AM_GNU_GETTEXT_VERSION): Update to 0.18.2.
This is necessary to have the gettext-provided m4 files to use
AC_PROG_MKDIR_P rather than AM_PROG_MKDIR_P. This latter macro,
planned to disappear in Automake 1.14, has already been removed
in the development version of Automake, so that, without this
change, grep fails to bootstrap with bleeding-edge Automake.
2013-01-11 Paul Eggert
build: update gnulib submodule to latest
2013-01-11 Stefano Lattarini
build: remove redundant use of $(INCLUDES)
* lib/Makefile.am (INCLUDES): Remove. Automake automatically adds
$(srcdir) and $(top_builddir) to the C preprocessor search path.
INCLUDES is deprecated in Automake 1.13 (causing a runtime
warning), and will be removed in Automake 1.14.
2013-01-04 Jim Meyering
build: update gnulib submodule to latest
maint: update all copyright year number ranges
Run "make update-copyright".
2012-11-20 Paul Eggert
grep: normalize diagnostics
* src/pcresearch.c (Pcompile): Use similar format diagnostics
as elsewhere, and translate them.
2012-11-19 Paul Eggert
grep: diagnose read errors from -f dir, porting to Solaris
Problem reported by Dennis Clarke for Solaris 10 in
.
* src/main.c (main): For -f F, diagnose any read errors
encountered when reading F.
* tests/Makefile.am (XFAIL_TESTS): Remove grep-dir.
* tests/grep-dir: Don't assume that directories cannot be read
via fread, as POSIX allows this and it can happen on Solaris.
2012-11-09 Paolo Bonzini
pcre: add PCRE-JIT support for grep
* NEWS: Document new feature.
* src/pcresearch.c [PCRE_STUDY_JIT_COMPILE] (jit_stack): New.
[PCRE_STUDY_JIT_COMPILE] (Pcompile): JIT-compile the regular expression
and allocate a stack for it. Based on a patch from Zoltan Herczeg.
* THANKS: Add Zoltan to the list.
2012-10-24 Paul Eggert
build: go back to AC_PROG_CC
* configure.ac: Go back to using AC_PROG_CC rather than AC_PROG_CC_STDC,
as the latter is obsolescent and the Autoconf bug involving the former
has been fixed.
2012-10-24 Jim Meyering
build: use AC_PROG_CC_STDC rather than AC_PROG_CC
* configure.ac: Use AC_PROG_CC_STDC rather than AC_PROG_CC,
to accommodate autoconf-2.69-37+.
build: update gnulib submodule to latest
2012-10-23 Eric Blake
build: default to --enable-gcc-warnings in a git tree
Anyone building from cloned sources can be assumed to have a new
enough environment, such that enabling gcc warnings by default will
be useful. Tarballs still default to no warnings, and the default
can still be overridden with --disable-gcc-warnings.
* configure.ac (gl_gcc_warnings): Set default based on environment.
2012-10-03 Jim Meyering
maint: factor out STREQ definition
* src/main.c (STREQ): Remove definition.
* src/pcresearch.c: (STREQ): Likewise.
* src/system.h (STREQ): Define it here instead.
maint: correct syntax-check failures; adjust NEWS
* tests/pcre-utf8: Reverse order of compare arguments.
Remove all copyright year numbers except 2012.
Use skip_ "diagnostic...", rather than a bare "exit 77".
* NEWS: Start with a concise description of the bug.
* src/pcresearch.c (STREQ): Define, so that we can...
(Pcompile): use STREQ, not strcmp.
2012-10-03 Paolo Bonzini
tests: include UTF-8 testcases for grep -P
* tests/Makefile.am (TESTS): Add pcre-utf8.
* tests/pcre-utf8: New file.
2012-10-03 Petr Pisar
pcresearch: set UTF-8 flag correctly for UTF-8 locales
Otherwise, Unicode properties (\p{XXX}) do not work with characters
outside the 7-bit ASCII character set.
* src/pcresearch.c (Pcompile): Look for UTF-8 locales and set PCRE_UTF8
if one is found.
2012-10-03 Jaroslav Å karvada
doc: fix a formatting bug in grep.1 template
* doc/grep.in.1: Insert .TP before the paragraph describing
--dereference-recursive (-R).
2012-10-03 Jim Meyering
maint: placate gcc's -Wjump-misses-init warning
* src/kwsearch.c (Fexecute): Replace a "goto" and "return" with
a simple return statement, eliminating the label, since that was
the sole use.
* src/dfasearch.c (EGexecute): Likewise.
2012-09-01 Jim Meyering
build: update gnulib submodule to latest
2012-09-01 Eric Blake
build: work with new glibc when not optimizing
Starting with glibc 2.15, the system headers refuse to compile
unconditional use of FORTIFY_SOURCE if optimization is disabled
but -Werror is in effect.
* configure.ac (FORTIFY_SOURCE): Make conditional.
2012-08-19 Jim Meyering
maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
version 2.14
* NEWS: Record release date.
2012-08-07 Jim Meyering
build: update gnulib and bootstrap
tests: test for bug with -i and ^$ in a multi-byte locale
* tests/empty-line-mb: New file.
* tests/Makefile.am (TESTS): Add it.
grep -i '^$' in a multi-byte locale could report a false match
* src/dfasearch.c (EGexecute): Do not match the sentinel "newline"
that is appended to each buffer.
This bug may sound like a big deal (it certainly surprised me), but
realize that only the empty-line-matching regular expression '^$'
can trigger it, and then only when you add the unnecessary (and
arguably superfluous) -i, *and* run the command in a multi-byte
locale. Using a multi-byte locale for such a regular expression
is also pointless, and hurts performance.
* NEWS (Bug fixes): Mention it.
Reported by Alexander Katassonov
2012-08-06 Jim Meyering
tests: fix a skip diagnostic that mentioned the wrong locale
* tests/init.cfg (require_tr_utf8_locale_): s/en_US/tr_TR/
2012-08-02 Jim Meyering
tests: skip failing test on FS/system that lack SEEK_HOLE support
* tests/big-hole: Test for SEEK_HOLE support. If not available,
skip this test. Hence, this test is now skipped on linux-3.5.0 with
ext4 or tmpfs. The test runs (and passes) with at least btrfs, xfs,
or ocfs2.
* bootstrap.conf (gnulib_modules): Use the perl module.
2012-07-30 Jim Meyering
maint: optimize long-line processing
* src/main.c (grep): Use memrchr rather than an open-coded loop,
reducing the cost of the replaced code by 50% when processing very
long lines. If there were a rawmemrchr function (analogous to glibc's
rawmemchr), then the performance improvement would be even greater.
2012-07-27 Paul Eggert
maint: remove stat-size
* bootstrap.conf (gnulib_modules): Remove stat-size.
* src/main.c: Don't include stat-size.h; no longer needed.
grep: don't falsely report compressed text files as binary
* NEWS: Document this.
* src/main.c (file_is_binary): Remove the heuristic based on
st_blocks, as it does not work for compressed file systems.
On Solaris, it'd be cheap to test whether the file system is known
to be uncompressed, which allow the heuristic, but Solaris has
SEEK_HOLE so there's little point.
grep: don't falsely report tiny text files as binary
* NEWS: Document this.
* src/main.c (file_is_binary): When we are already at apparent
EOF, skip the file-size check, as some servers use zero blocks
to store binary files. Reported by Martin Carroll in
.
2012-07-26 Paul Eggert
doc: document -r/-R in man page
* doc/grep.in.1: Document -r vs. -R.
2012-07-21 Jim Meyering
tests: avoid false positive upon kernel OOM-kill
* tests/big-match (skip_diagnostic): Handle case of 139 (SIGKILL)
with no diagnostic.
build: update gnulib and bootstrap
maint: fix misspellings in old ChangeLog
* ChangeLog-2009: Fix typos.
2012-07-19 Paul Eggert
grep: fix ptrdiff/size_t clash
Reported by Jaroslav Å karvada in .
* src/dfasearch.c (EGexecute): Use size_t, not ptrdiff_t, for lengths.
Use regoff_t to store re_match's output, and test it before converting
it to size_t.
2012-07-06 Jim Meyering
maint: correct log typo, to reflect in generated ChangeLog
* Makefile.am (gen-ChangeLog): Use --amend, now that we must
make our first log correction.
* build-aux/git-log-fix: New file.
2012-07-04 Jim Meyering
maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
version 2.13
* NEWS: Record release date.
build: update gnulib submodule, bootstrap, init.sh
2012-06-17 Jim Meyering
tests: add another turkish-I-related test case
* tests/turkish-I-without-dot: Also exercise the case in which
the original string and the lower-case buffer have precisely
the same length (22 bytes here), yet internal offsets do differ.
2012-06-16 Jim Meyering
grep -i: work also when converting to lower-case inflates byte count
Commit v2.12-16-g7aa698d addressed the case in which the lower-case
representation of an input byte occupies fewer bytes than the original.
However, even with commit v2.12-20-g074842d, grep -i would still
misbehave when converting a character to lower-case increased its
byte count. The map-manipulation code assumed that the case conversion
could only shrink the byte count. With the consideration that it may
also inflate it, the deltas recorded in the map array must be signed,
and we must account for the one-to-two-or-more mapping when the
original-to-lower-case conversion causes the byte count to increase.
* src/searchutils.c (mbtolower): When a lower-case character occupies
more than one byte, set its remaining map slots to zero. Change the
type of the map to be signed, and compute the change in character
byte count as new_length - old_length.
* src/search.h: Include , for decl of intmax_t.
(mb_case_map_apply): Adjust for signed increments:
each map entry is now signed.
(mb_len_map_t): Define type. Thanks to Paul Eggert for noticing
in review that using a bare "char" as the base type would be wrong on
systems for which it is a signed type (as with gcc's -funsigned-char).
* src/kwsearch.c (Fcompile, Fexecute): Likewise.
* src/dfasearch.c (kwsincr_case, EGexecute): Likewise.
* tests/turkish-I-without-dot: New test. Thanks to Paolo Bonzini
for the tip that in the tr_TR.utf8 locale, mapping "I" to lower case
increases the character's byte count.
* tests/Makefile.am (TESTS): Add it.
* tests/init.cfg (require_tr_utf8_locale_): New function.
* NEWS (Bug fixes): Expand the existing entry.
2012-06-12 Paul Eggert
grep: handle -i when chars differ in length but line does not
* src/searchutils.c (mbtolower): Return the map back to the caller
if any input character's length differs from the corresponding output
character's, not merely if the total string length differs.
Problem reported by Johannes Meixner in
.
2012-06-07 Jim Meyering
tests: extend coverage of dfa.c's match_mb_charset
Add a test case to increase test coverage of part of dfa.c (the DFA
matcher used by grep and gawk). While thinking about removing the few
remaining uses of strncpy in dfa.c, I found that none of the existing
tests covered the 40+ lines of code at the end of match_mb_charset,
so constructed this test case to demonstrate that it's not dead code
* tests/dfa-coverage: New test, for improved coverage.
* tests/Makefile.am (TESTS): Add it.
2012-06-05 Jim Meyering
build: fix a subtly twisted "make distcheck" failure
"make distcheck" would fail when, during a test build,
an attempt to overwrite the deliberately-write-protected
$(srcdir)/grep.pot file would fail.
* bootstrap.conf (bootstrap_epilogue): Don't let the existence of
a large sparse file in the build directory induce "make distcheck"
failure. The existence of a large sparse test file named 8T-or-so
would make po/Makefile.in.in's use of grep (to search for "GNU grep"
as an indication that this is a GNU package) exit 2 without generating
any output, which made the first xgettext use --package-name=grep,
while that same search for "GNU grep" would succeed when run
from a pristine from-tarball build, thus making the second
xgettext invocation use --package-name='GNU grep'.
That mismatch:
-"Project-Id-Version: grep 2.12.18-1080\n"
+"Project-Id-Version: GNU grep 2.12.18-1080\n"
led to the attempt by Makefile.in.in's grep.pot-update rule to
overwrite ../../grep.pot in the read-only po/ source directory.
2012-06-03 Jim Meyering
build: update gnulib submodule, bootstrap and init.sh
cfg.mk: Exempt dfa.c from the new no-strncpy test, for now.
2012-06-02 Jim Meyering
grep: fix how -i works with a match containing the Turkish I-with-dot
Fix a long-standing problem in the way grep's -i interacts with
data whose byte count changes when we convert it to lower case.
For example, the UTF-8 Turkish I-with-dot (İ) occupies two bytes,
but its lower case analog, i, occupies just one byte. The code
converts both search string and the haystack data to lower case,
and then searches for the modified string in the modified buffer.
The trouble arose when using a lowercase buffer
pair to manipulate the original (longer) buffer.
The solution is to change mbtolower to return additional information:
a malloc'd mapping vector. With that, the caller maps the lowercase-
relative to numbers that refer to the original buffer.
This mapping is used only when lengths actually differ, so the cost
in general should be small.
* src/searchutils.c (mbtolower): Add the new map parameter.
* src/search.h (mb_case_map_apply): New function.
* src/kwsearch.c (Fexecute): Update mbtolower caller, and upon
success, apply the new map.
* src/dfasearch.c (EGexecute): Likewise.
* tests/Makefile.am (XFAIL_TESTS): Remove turkish-I from this list;
that test is no longer expected to fail.
* NEWS (Bug fixes): Mention it.
Reported by Ilya Basin in
http://thread.gmane.org/gmane.comp.gnu.grep.bugs/3413 and later
by Strahinja Kustudic in http://savannah.gnu.org/bugs/?36567
2012-06-01 Paul Eggert
grep: remove unnecessary "what-if-signal?" code
* src/main.c (fillbuf): Don't worry about EINTR when closing --
not possible, since we're not catching signals.
2012-05-16 Paul Eggert
grep: avoid nominal integer overflow
* src/dfa.c (add_utf8_anychar): Avoid signed integer overflow.
Although this works on all platforms we know about, strictly
speaking the behavior is undefined, and Sun C 5.8 warns about it.
2012-05-15 Jim Meyering
maint: avoid nit-picky syntax-check test failure; tweak big-hole test
* NEWS: Restore deleted newline in "old" NEWS, to fix a syntax-check
test failure.
* tests/big-hole: Use awk, rather than a shell loop: saves 3000 lines
of verbose shell output in the .log file.
2012-05-15 Paul Eggert
grep: sparse files are now considered binary
* NEWS: Document this.
* doc/grep.texi (File and Directory Selection): Likewise.
* bootstrap.conf (gnulib_modules): Add stat-size.
* src/main.c: Include stat-size.h.
(usable_st_size): New function, mostly stolen from coreutils.
(fillbuf): Use it.
(file_is_binary): New function, which looks for holes too.
(grep): Use it.
* tests/Makefile.am (TESTS): Add big-hole.
* tests/big-hole: New file.
2012-05-06 Paul Eggert
maint: quote 'like this' or "like this", not `like this'
See .
* ChangeLog-2009, HACKING, NEWS, README-hacking, cfg.mk, configure.ac:
* lib/colorize-w32.c, m4/pcre.m4:
* src/Makefile.am, src/dfa.c, src/dosbuf.c, src/main.c:
* tests/backref, tests/help-version, tests/tests:
In commentary, quote 'like this' or "like this" rather than
`like this' or ``like this''.
* cfg.mk (old_NEWS_hash): Update due to changed old NEWS.
* doc/grep.texi (General Output Control): Quote sample text
with @samp, not with `...'.
* src/main.c (usage):
* tests/help-version: Quote 'like this' rather than `like this'
in diagnostics.
exclude: process exclude and include directives in order
Also, change exclude and include directives so that they apply to
command-line arguments too. This restores the pre-2.6 behavior,
and fixes a bug reported by Quentin Arce in
.
* NEWS: Document this.
* src/main.c (included_patterns): Remove. All uses removed.
(skipped_file): New function.
(grepdirent): New arg command_line; all callers changed. This is
needed because non-command-line files can invoke fts_open, and
their directory entries need to be distinguished from top-level
directory entries. Move code into the new skipped_file function.
(grepdesc): Check whether a command-line argument should be skipped.
(main): --include and --exclude options now share excluded_patterns
rather than having separate variables included_patterns and
excluded_patterns.
* tests/include-exclude: Add a test to detect the fixed bug.
build: update gnulib submodule to latest
2012-04-30 Jim Meyering
cosmetic: binary operator goes *after* the newline, when split
* src/dfa.c (match_mb_charset): Join split lines.
(parse_bracket_exp): Move "||" from end of first split line
to the beginning of the continued line.
* src/dosbuf.c (dossified_pos): Likewise, but for "&&".
grep: -K is not an option: remove it from list
The presence of "K" in the short-option string meant that
an erroneous "grep -K ..." would fail with a bare Usage/Try...
message, without the usual "invalid option -- 'K'". With this
removal, now grep prints the expected invalid option diagnostic.
* src/main.c (short_options): Remove "K".
Reported by Петр ДоÑычев in
http://thread.gmane.org/gmane.comp.gnu.grep.bugs/4488
2012-04-29 Paolo Bonzini
dfa: small fixes to single-byte range computation
* src/dfa.c (parse_bracket_exp): Do not call regexec with an invalid
subject. Move declarations before all statements.
2012-04-27 Paolo Bonzini
dfa: do not use hard-locale
* bootstrap.conf (gnulib_modules): Remove hard-locale.
* src/dfa.c (hard_LC_COLLATE): Remove.
(dfaparse): Do not initialize it.
(parse_bracket_exp): Always go through system regex matcher to find
single byte characters matching a range.
drop support for Makefile.boot
* Makefile.am: Do not distribute README-boot and Makefile.boot.
* NEWS: Mention this change.
* README-alpha: Do not mention README-boot and Makefile.boot.
* Makefile.boot: Remove.
* README-boot: Remove.
2012-04-27 Aharon Robbins
dfa: do not use strcoll to match multibyte characters in ranges
This does not affect the behavior of grep, which always defers
to glibc or gnulib when matching ranges.
* src/dfa.c (match_mb_charset): Compare wc directly to the range
endpoints.
dfa: include stdbool.h explicitly
* src/dfa.c: Include stdbool.h explicitly
2012-04-23 Jim Meyering
maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
version 2.12
* NEWS: Record release date.
build: update gnulib submodule to latest
tests: skip annoyingly long gnulib lock tests
* bootstrap.conf (avoided_gnulib_modules): Define.
(gnulib_tool_option_extras): Use it.
2012-04-22 Jim Meyering
tests: avoid spurious quote-mismatch failure on OS/X
* tests/in-eq-out-infloop: Simplify expected error output, eliminating
expected quotes altogether, thus avoiding spurious OS/X-specific
failure due to mismatch of multi-byte vs. single-byte quotes.
2012-04-17 Jim Meyering
build: update gnulib submodule to latest
* bootstrap: Also update this file.
2012-04-17 Jim Meyering
grep: fix --devices=ACTION (-D) so stdin is once again exempt
An oversight in the 2.11 changes made it so "echo x|grep x" would
fail for those who set GREP_OPTIONS=--devices=skip.
* src/main.c (grepdesc): Ignore skip-related options when reading
from standard input.
* tests/skip-device: New file. Test for the above.
* tests/Makefile.am (TESTS): Add it.
* doc/grep.texi (File and Directory Selection): Clarify this point,
documenting the stdin exemption.
* NEWS (Bug fixes): Mention it, and add a few "[fixed in ...] notes.
Reported by Tino Keitel in http://bugs.debian.org/669084,
and forwarded to bug-grep by AnÃbal Monsalve Salazar.
2012-04-13 Jim Meyering