2014-02-20  Jim Meyering  <meyering@fb.com>

	version 2.18
	* NEWS: Record release date.

	tests: test for the non-UTF8 multi-byte performance regression
	Test for the just-fixed performance regression.
	With a 100-200x differential, it is reasonable to expect that
	a very slow system will be able to complete the designated
	task in a few seconds, while with the bug, even a very fast
	system would exceed the timeout.
	* tests/mb-non-UTF8-performance: New file.
	* tests/Makefile.am (TESTS): Add it.
	* tests/init.cfg (require_JP_EUC_locale_): New function.

	grep -i: avoid a performance regression in multibyte non-UTF8 locales
	* src/main.c: Include dfa.h.
	(trivial_case_ignore): Perform this optimization only for UTF8 locales.
	This rectifies a 100-200x performance regression in non-UTF8 multi-byte
	locales like ja_JP.eucJP.  The regression was introduced by the 10x
	UTF8/grep-i speedup, commit v2.16-4-g97318f5.
	* NEWS (Bug fixes): Mention it.
	Reported by Norihiro Tanaka in http://debbugs.gnu.org/16232#50

	maint: give dfa.c's using_utf8 function external scope
	* src/dfa.c (using_utf8): Remove "static inline".
	* src/dfa.h (using_utf8): Declare it.
	* src/searchutils.c (is_mb_middle): Use using_utf8 rather than
	rolling our own.

2014-02-20  Paul Eggert  <eggert@cs.ucla.edu>

	tests: test [^^-^] in unibyte locales
	This is a bug in the current dfa.c, which was reintroduced by the
	recent reversion from RRI.
	* tests/unibyte-negated-circumflex: New file.
	* tests/Makefile.am (TESTS): Add it.
	* tests/init.cfg (require_unibyte_locale): New function.

	grep: fix bug with patterns like [^^-~] in unibyte locales
	* NEWS: Document this.
	* src/dfa.c (parse_bracket_exp): Escape patterns like [^^-~], or
	Awk patterns like [\^-\]], so that they are not misinterpreted by
	the system regex library.  Check for system regex failure due to
	memory exhaustion.

2014-02-17  Jim Meyering  <meyering@fb.com>

	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.17
	* NEWS: Record release date.

2014-02-17  Paolo Bonzini  <bonzini@gnu.org>

	revert "grep: DFA now uses rational ranges in unibyte locales"
	The correct course of action for grep is to defer range interpretation
	to regex, because otherwise you can get mismatches between regexes with
	backreferences and those without.

	For example, [A-Z]. will use RRI but ([A-Z])\1 won't, with the confusing
	result that the first regex won't match a superset of the language
	described by the second regex.

	The source of the confusion is that, even though grep's dfa.c was changed
	to use range checking instead of strcoll, that code is only invoked if
	dfaexec is called with backref = NULL, and that never happens for grep!

	In the end, all that's needed for RRI is compiling --with-included-regex,
	and in that case the patch is almost a no-op.  Almost, because there
	are corner cases that aren't handled correctly (e.g. [a-[.e.]], or
	regular expressions that include a NUL character), but this can be
	handled separately.

	* NEWS: Revert paragraph introduced by commit v2.16-7-g1078b64.
	* src/dfa.c (parse_bracket_exp): Revert back to regcomp/regexec.

2014-02-16  Mike Frysinger  <vapier@gentoo.org>

	maint: ignore configure.lineno
	* .gitignore: Add configure.lineno.

2014-02-11  Benno Schulenberg  <bensberg@justemail.net>

	help: remove surplus newline
	* src/main.c (usage): Remove inconsistent \n introduced by previous
	patch.

2014-02-10  Benno Schulenberg  <bensberg@justemail.net>

	help: fix a line ending, and use the same word for similar things
	* src/main.c (usage): Change a stray 'n' to a newline, and use
	the word "display" for showing version info as for help text.

2014-02-09  Norihiro Tanaka  <noritnk@kcn.ne.jp>

	speed up mb-boundary-detection after each preliminary match
	After each kwsexec or dfaexec match, we must determine whether
	the tentative match falls in the middle of a multi-byte character.
	That is what our is_mb_middle function does, but it was expensive,
	even when most input consisted of single-byte characters.  The main
	cost was for each call to mbrlen.  This change constructs and uses
	a cache of the lengths returned by mbrlen for unibyte values.
	The largest speed-up (3x to 7x, CPU-dependent) is when most
	lines contain a match, yet few are printed, e.g., when using
	grep -v common-pattern ... to filter out all but a few lines.

	* src/search.h (build_mbclen_cache): Declare it.
	* src/main.c: Include "search.h".
	[MBS_SUPPORT] (main): Call build_mbclen_cache in a multibyte locale.
	* src/searchutils.c [HAVE_LANGINFO_CODESET]: Include <langinfo.h>.
	(mbclen_cache): New global.
	(build_mbclen_cache): New function.
	(is_mb_middle) [HAVE_LANGINFO_CODESET]: Use it.
	* NEWS (Improvements): Mention it.

2014-02-01  Jim Meyering  <meyering@fb.com>

	maint: use to_uchar function rather than explicit casts
	* src/system.h (to_uchar): Define function.
	* src/kwsearch.c (Fexecute): Use to_uchar twice in place of casts.
	* src/dfasearch.c (EGexecute): Likewise.
	* src/main.c (prepend_args): Likewise.
	* src/kwset.c (U): Define in terms of to_uchar.
	* src/dfa.c (match_mb_charset): Use to_uchar, not an explicit cast.

2014-01-27  Jim Meyering  <meyering@fb.com>

	maint: remove vestiges of support for long-disabled --mmap option
	This option was disabled in March of 2010, and began to elicit a
	warning in January of 2012.  Its time has come.
	* doc/grep.in.1: Remove mention.
	* doc/grep.texi: Likewise.
	* src/main.c (GROUP_SEPARATOR_OPTION, usage, MMAP_OPTION)
	(long_options, main): Remove all traces.
	* tests/Makefile.am (check_PROGRAMS): Remove mention of ignore-mmap.
	* tests/ignore-mmap: Remove file.
	* NEWS (Maintenance): Mention it.

2014-01-26  Jim Meyering  <meyering@fb.com>

	maint: move two local variable declarations
	* src/dfasearch.c (kwsmusts): Move one declaration down to the point
	of definition.  Move another into the sole scope where it is used.

2014-01-26  Norihiro Tanaka  <noritnk@kcn.ne.jp>

	dfasearch: skip kwset optimization when multi-byte+case-insensitive
	Now that DFA searching works with multi-byte locales, the only remaining
	reason to case-convert the searched input is the kwset optimization.
	But multi-byte case-conversion is so expensive that it's not
	worthwhile even to attempt that optimization.

	* src/dfasearch.c (kwsmusts): Skip this function in ignore-case mode
	when the locale is multi-byte.
	(EGexecute): Now that this code need not handle multi-byte case-ignoring
	matches, remove the expensive copy/case-conversion code.
	With no case-converted buffer, there is no longer any need to call
	mb_case_map_apply, so remove it and associated code.
	(kwsincr_case): Remove function.  Now, every use of this function
	is equivalent to a use of kwsincr.  Replace all uses.
	* tests/turkish-eyes: Test all of -E, -F and -G.

2014-01-25  Norihiro Tanaka  <noritnk@kcn.ne.jp>

	dfa: remove GREP-ifdef'd code in favor of code used by gawk
	For many years, gawk and grep have used different #ifdef'd bits of
	code relating to how the DFA matcher matches multibyte characters.
	Remove the GREP-specific code in favor of the code gawk uses.  This
	permits us to avoid still more cases in which grep must resort to
	the expensive process of copying/case-converting each input line
	before matching against a case-converted regexp.
	* src/dfa.c (parse_bracket_exp, atom): As above.

2014-01-25  Jim Meyering  <meyering@fb.com>

	gnulib: update to latest

2014-01-17  Paul Eggert  <eggert@cs.ucla.edu>

	grep: DFA now uses rational ranges in unibyte locales
	Problem reported by Aharon Robbins in <http://bugs.gnu.org/16481>.
	* NEWS:
	* doc/grep.texi (Environment Variables)
	(Character Classes and Bracket Expressions):
	Document this.
	* src/dfa.c (parse_bracket_exp): Treat unibyte locales like multibyte.

2014-01-17  Aharon Robbins  <arnold@skeeve.com>

	grep: add undocumented '-X gawk' and '-X posixawk' options
	See <http://bugs.gnu.org/16481>.
	* src/grep.c (GAcompile, PAcompile): New functions.
	(const): Use them.

2014-01-10  Pádraig Brady  <P@draigBrady.com>

	tests: remove superfluous uses of printf
	* tests/turkish-eyes: Remove unnecessary uses of printf.

2014-01-09  Jim Meyering  <meyering@fb.com>

	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  <eggert@cs.ucla.edu>

	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 <http://bugs.gnu.org/16380>.
	* 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  <meyering@fb.com>

	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  <meyering@fb.com>

	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  <meyering@fb.com>

	maint: fix inconsistent spacing in expression
	* src/main.c (prline): Fix inconsistent spacing in expression:
	s/  / /.

2013-12-26  behoffski  <behoffski@grouse.com.au>

	maint: fix a garbled comment
	* src/dfa.c (XNMALLOC, etc.): Fix garbled comment wording.

2013-12-23  Jim Meyering  <meyering@fb.com>

	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  <santiago@debian.org>

	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  <meyering@fb.com>

	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  <meyering@fb.com>

	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  <meyering@fb.com>

	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  <meyering@fb.com>

	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  <meyering@fb.com>
	    Paul Eggert  <eggert@cs.ucla.edu>

	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  <meyering@fb.com>

	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  <meyering@fb.com>

	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  <meyering@fb.com>

	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  <eggert@cs.ucla.edu>

	build: port to AIX
	Problem reported by Pavel Kharitonov in <http://bugs.gnu.org/15690#68>.
	* 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  <meyering@fb.com>

	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  <meyering@fb.com>

	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  <meyering@fb.com>

	gnulib: update to latest

	maint: remove now-unused wcscoll module
	* bootstrap.conf (gnulib_modules): Remove wcscoll; no longer used.

2013-10-20  Paul Eggert  <eggert@cs.ucla.edu>

	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  <meyering@fb.com>

	build: update gnulib submodule to latest

2013-10-19  Jim Meyering  <meyering@fb.com>

	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  <meyering@fb.com>

	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  <meyering@fb.com>

	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  <meyering@fb.com>

	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  <meyering@fb.com>

	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  <meyering@fb.com>

	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  <vinschen@redhat.com>

	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  <eggert@cs.ucla.edu>

	doc: mention how to use the latest gnulib
	* README-hacking: Steal some text from coreutils/README-hacking.

2013-08-10  Jim Meyering  <meyering@fb.com>

	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  <meyering@fb.com>

	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  <eggert@cs.ucla.edu>

	Redo comments and white space to better approach GNU style.

2013-07-05  Paolo Bonzini  <bonzini@gnu.org>

	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  <mike@ducky.net>

	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:

	        <RPN representation for a>
	        <RPN representation for a>
	        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  <meyering@fb.com>

	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  <eggert@cs.ucla.edu>

	* cfg.mk (old_NEWS_hash): Update.

	doc: document EREs like a{,10}
	Problem reported by Eric Blake in
	<http://lists.gnu.org/archive/html/bug-grep/2013-04/msg00005.html>.
	* 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  <eggert@cs.ucla.edu>

	build: make dfa.c closer to Gawk's
	* src/dfa.c: Include <stddef.h>, not <sys/types.h>.
	stddef.h is smaller and is all we need and is portable nowadays.
	Include <wchar.h> and <wctype.h> only if MBS_SUPPORT.

2013-01-15  Paul Eggert  <eggert@cs.ucla.edu>

	grep: make dfa.h standalone
	Problem reported by Aharon Robbins in
	<http://lists.gnu.org/archive/html/bug-grep/2013-01/msg00007.html>.
	* src/dfa.c: Include dfa.h first, so that it's tested standalone.
	No need to include <regex.h>, since we are in charge of dfa.h and
	know that it includes <regex.h>.
	* src/dfa.h: Include <regex.h> and <stddef.h>, so that it's standalone.

2013-01-11  Stefano Lattarini  <stefano.lattarini@gmail.com>

	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  <eggert@cs.ucla.edu>

	build: update gnulib submodule to latest

2013-01-11  Stefano Lattarini  <stefano.lattarini@gmail.com>

	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  <jim@meyering.net>

	build: update gnulib submodule to latest

	maint: update all copyright year number ranges
	Run "make update-copyright".

2012-11-20  Paul Eggert  <eggert@cs.ucla.edu>

	grep: normalize diagnostics
	* src/pcresearch.c (Pcompile): Use similar format diagnostics
	as elsewhere, and translate them.

2012-11-19  Paul Eggert  <eggert@cs.ucla.edu>

	grep: diagnose read errors from -f dir, porting to Solaris
	Problem reported by Dennis Clarke for Solaris 10 in
	<http://lists.gnu.org/archive/html/bug-grep/2012-11/msg00009.html>.
	* 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  <bonzini@gnu.org>

	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  <eggert@cs.ucla.edu>

	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  <jim@meyering.net>

	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  <eblake@redhat.com>

	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  <meyering@redhat.com>

	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  <bonzini@gnu.org>

	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  <ppisar@redhat.com>

	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  <jskarvad@redhat.com>

	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  <meyering@redhat.com>

	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  <meyering@redhat.com>

	build: update gnulib submodule to latest

2012-09-01  Eric Blake  <eblake@redhat.com>

	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  <meyering@redhat.com>

	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  <meyering@redhat.com>

	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 <katasso@gmx.de>

2012-08-06  Jim Meyering  <meyering@redhat.com>

	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  <meyering@redhat.com>

	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  <meyering@redhat.com>

	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  <eggert@cs.ucla.edu>

	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
	<http://lists.gnu.org/archive/html/bug-grep/2012-07/msg00016.html>.

2012-07-26  Paul Eggert  <eggert@cs.ucla.edu>

	doc: document -r/-R in man page
	* doc/grep.in.1: Document -r vs. -R.

2012-07-21  Jim Meyering  <meyering@redhat.com>

	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  <eggert@cs.ucla.edu>

	grep: fix ptrdiff/size_t clash
	Reported by Jaroslav Škarvada in <http://savannah.gnu.org/bugs/?36883>.
	* 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  <meyering@redhat.com>

	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  <meyering@redhat.com>

	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  <meyering@redhat.com>

	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  <meyering@redhat.com>

	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
