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

	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-28  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.

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

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

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

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

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

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

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

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

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

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

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

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

	maint: quote 'like this' or "like this", not `like this'
	See <http://lists.gnu.org/archive/html/bug-grep/2012-01/msg00125.html>.
	* 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
	<http://lists.gnu.org/archive/html/bug-grep/2012-04/msg00056.html>.
	* 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  <meyering@redhat.com>

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

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

	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  <arnold@skeeve.com>

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

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

	build: update gnulib submodule to latest
	* bootstrap: Also update this file.

2012-04-17  Jim Meyering  <meyering@redhat.com>

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

	maint: dfa: correct bogus formatting
	* src/dfa.c (transit_state, dfaexec): s/++ * VAR/++*VAR/

	maint: dfa: add/improve comments
	* src/dfa.c (transit_state_consume_1char): Note always-ignored
	return value.
	Fix typos: s/equivalent class/equivalence class/.

	maint: dfa: avoid unnecessary uses of strcpy/strncpy
	* src/dfa.c (icatalloc): Use memcpy, not strcpy, given the length.
	(dfamust): Combine MALLOC+strcpy into cleaner xmemdup.
	(parse_bracket_exp): Likewise, but replace a use of strncpy.

	grep: handle symlinked directory loops as usual
	* src/main.c (grepfile): Treat EMLINK just like ELOOP, for
	systems like FreeBSD 9.0 on which we would otherwise report
	"Too many links" rather than ignoring that type of failure.
	E.g., "mkdir d; cd d; ln -s . a; grep -r ^" would print
	grep: a: Too many links and would exit with status 2.
	Now, it prints nothing and exits with status 1, as before.
	Reported by Nelson H. F. Beebe.

	tests: avoid spurious failure of the symlink test
	* tests/symlink: Ignore spurious "Binary file d matches" on
	systems for which reading from a directory actually succeeds.
	Reported by Bruno Haible and Nelson Beebe.

2012-04-09  Jim Meyering  <meyering@redhat.com>

	tests: avoid syntax-check failure: reverse compare arguments
	* tests/repetition-overflow: Fix reversed compare arguments.

	build: update gnulib submodule to latest

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

	grep: report overflow for ERE a{1000000000}
	* NEWS: Document this.
	* src/dfa.c (MIN): New macro.
	(lex): Lexically analyze the repeat-count operator once, not
	twice; the double-scan complicated the code and made it harder to
	understand and fix.  Adjust the repeat-count parsing so that it
	better matches the behavior of the regex code, in three ways:
	1. Diagnose too-large repeat counts rather than treating them as
	literal characters.  2. Use RE_INVALID_INTERVAL_ORD, not
	RE_NO_BK_BRACES, to decide whether to treat invalid-syntax {...}s
	as literals.  3. Use the same wording for {...}-related
	diagnostics that the regex code uses.
	* tests/bre.tests, tests/ere.tests, tests/repetition-overflow:
	Adjust to match new behavior, and add a few tests.
	* cfg.mk (exclude_file_name_regexp--sc_error_message_uppercase):
	New macro, since the diagnostics start with uppercase letters.

2012-03-15  Paul Eggert  <eggert@cs.ucla.edu>

	grep: -r no longer follows symlinks; use fts
	Change -r to follow only command-line symlinks, and by default to
	read only devices named on the command line.  This is a simple
	way to get a more-useful behavior when searching random
	directories; the idea is to use 'find' if you want something fancy.
	-R acts as before and gets a new alias --dereference-recursive.
	The code now uses fts internally, so it is more robust and
	faster with large hierarchies.
	* .gitignore: Remove lib/savedir.c, lib/savedir.h.
	* tests/symlink: New file
	* Makefile.boot (LIB_OBJS_core): Remove isdir.o, savedir.o.
	Perhaps other changes are needed too, but I'm not sure what
	this makefile is for.
	* NEWS: Document changes.
	* doc/grep.texi (File and Directory Selection): Likewise.
	* bootstrap.conf (gnulib_modules): Remove dirent, dirname, isdir, open.
	Add fstatat, fts, openat-safer.
	* lib/Makefile.am (libgreputils_a_SOURCES): Remove savedir.c, savedir.h.
	* lib/savedir.c, lib/savedir.h: Remove.
	* po/POTFILES.in: Add lib/openat-die.c.
	* src/main.c: Include fcntl-safer.h, fts_.h.  Don't include
	isdir.h, savedir.h.
	(struct stats, stats_base): Remove.
	(long_options, usage, main): Add --dereference-recursive and
	implement -r vs -R.
	(filename_prefix_len, fts_options): New static vars.
	(basic_fts_options, READ_COMMAND_LINE_DEVICES): New constants.
	(devices): Now defaults to READ_COMMAND_LINE_DEVICES.
	(reset, grep): Now takes just struct stat rather than file name and
	struct stats.  All callers changed.
	(fillbuf): Now takes struct stat reather than struct stats.
	All callers changed.
	(grep): Don't worry about recursing too deeply; fts and grepdesc
	handle this now.
	(is_device_mode, grepdirent, grepdesc, grep_command_line_args):
	New functions.
	(grepfile): New args DIRDESC, FOLLOW, COMMAND_LINE.  Remove struct stats
	arg.  All callers changed.  Use openat_safer rather than open.
	Use desc == STDIN_FILENO to tell whether we're reading "-".
	Don't worry about EINTR when closing -- not possible, since we're
	not catching signals.
	* tests/Makefile.am (TESTS): Add symlink.
	* tests/symlink: New file.

2012-03-12  Paul Eggert  <eggert@cs.ucla.edu>

	tests: port big-match to non-GNU dd
	* tests/big-match: Don't assume GNU dd extension "bs=1M".

	tests: test for bug with -r --exclude-dir and no file operand
	* tests/include-exclude: Test for the bug and fix.

2012-03-12  Allan McRae  <allan@archlinux.org>

	grep: fix segfault with -r --exclude-dir and no file operand
	* src/main.c (grepdir): Don't invoke excluded_file_name on NULL.
	* NEWS (Bug fixes): Mention it.

2012-03-09  Jim Meyering  <meyering@redhat.com>

	tests: exercise two recently-fixed bugs
	* tests/repetition-overflow: New test for bugs fixed by commit
	v2.10-82-gcbbc1a4.
	* tests/Makefile.am (TESTS): Add it.

2012-03-03  Jim Meyering  <meyering@redhat.com>

	maint: use an optimal-for-grep xz compression setting
	* cfg.mk (XZ_OPT): Use -6e (determined empirically, see comments).
	This sacrifices a meager 60 bytes of compressed tarball size for a
	55-MiB decrease in the memory required during decompression.  I.e.,
	using -9e would shave off only 60 bytes from the tar.xz file, yet
	would force every decompression process to use 55 MiB more memory.

	build: update gnulib submodule to latest

2012-03-02  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.11
	* NEWS: Record release date.

	tests: avoid failure when using Solaris 10's sed
	* tests/reversed-range-endpoints: Use a simpler sed expression to
	sanitize actual output, so it also works with Solaris 10's /bin/sed.

	maint: manually correct formatting in dfa.c's cpp definitions
	* src/dfa.c: Adjust formatting in cpp definitions.

	maint: indent dfa.c
	* src/dfa.c: Filter through indent like this:
	HOME=. indent -Tsize_t -l79 --leave-preprocessor-space \
	  --dont-format-comments --no-tabs < dfa.c > k && mv k dfa.c

	doc: correct grep.1's descriptions of \w and \W (they omitted "_")
	* doc/grep.in.1: Fix descriptions of \w and \W.
	They did not mention "_".
	* doc/grep.texi (The Backslash Character and Special Expressions):
	[\w, \W]: List the "_" before the char class, not after: [_[:alnum:]],
	for readability and to be consistent with the man page.

2012-03-02  Paul Eggert  <eggert@cs.ucla.edu>

	maint: spelling fixes

2012-03-01  Paul Eggert  <eggert@cs.ucla.edu>

	grep: fix integer-overflow issues in main program
	* NEWS: Document this.
	* bootstrap.conf (gnulib_modules): Add inttypes, xstrtoimax.
	Remove xstrtoumax.
	* src/main.c: Include <inttypes.h>, for INTMAX_MAX, PRIdMAX.
	(context_length_arg, prtext, grepbuf, grep, grepfile)
	(get_nondigit_option, main):
	Use intmax_t, not int, for line counts.
	(context_length_arg, main): Silently ceiling line counts
	to maximum value, since there's no practical difference between
	doing that and using infinite-precision arithmetic.
	(out_before, out_after, pending): Now intmax_t, not int.
	(max_count, outleft): Now intmax_t, not off_t.
	(prepend_args, prepend_default_options, main):
	Use size_t, not int, for sizes.
	(prepend_default_options): Check for int and size_t overflow.

	grep: avoid mishandling of long lines
	* src/pcresearch.c (Pexecute): Do not pass a line longer than
	INT_MAX to pcre_exec, since its API does not permit that.

	grep: remove no-longer-used setrlimit code
	This code has been unused and obsolescent ever since the regex
	code stopped using the stack for large regular expressions.
	* src/main.c [HAVE_SETRLIMIT]: Do not include <sys/time.h> or
	or <sys/resource.h>; no longer needed.
	(set_rlimits): Remove.  All callers changed.

	grep: fix some core dumps with long lines etc.
	These problems mostly occur because the code attempts to stuff
	sizes into int or into unsigned int; this doesn't work on most
	64-bit hosts and the errors can lead to core dumps.
	* NEWS: Document this.
	* src/dfa.c (token): Typedef to ptrdiff_t, since the enum's
	range could be as small as -128 .. 127 on practical hosts.
	(position.index): Now size_t, not unsigned int.
	(leaf_set.elems): Now size_t *, not unsigned int *.
	(dfa_state.hash, struct mb_char_classes.nchars, .nch_classes)
	(.nranges, .nequivs, .ncoll_elems, struct dfa.cindex, .calloc, .tindex)
	(.talloc, .depth, .nleaves, .nregexps, .nmultibyte_prop, .nmbcsets):
	(.mbcsets_alloc): Now size_t, not int.
	(dfa_state.first_end): Now token, not int.
	(state_num): New type.
	(struct mb_char_classes.cset): Now ptrdiff_t, not int.
	(struct dfa.utf8_anychar_classes): Now token[5], not int[5].
	(struct dfa.sindex, .salloc, .tralloc): Now state_num, not int.
	(struct dfa.trans, .realtrans, .fails): Now state_num **, not int **.
	(struct dfa.newlines): Now state_num *, not int *.
	(prtok): Don't assume 'token' is no wider than int.
	(lexleft, parens, depth): Now size_t, not int.
	(charclass_index, nsubtoks)
	(parse_bracket_exp, addtok, copytoks, closure, insert, merge, delete)
	(state_index, epsclosure, state_separate_contexts)
	(dfaanalyze, dfastate, build_state, realloc_trans_if_necessary)
	(transit_state_singlebyte, match_anychar, match_mb_charset)
	(check_matching_with_multibyte_ops, transit_state_consume_1char)
	(transit_state, dfaexec, free_mbdata, dfaoptimize, dfafree)
	(freelist, enlist, addlists, inboth, dfamust):
	Don't assume indexes fit in 'int'.
	(lex): Avoid overflow in string-to-{hi,lo} conversions.
	(dfaanalyze): Redo indexing so that it works with size_t values,
	which cannot go negative.
	* src/dfa.h (dfaexec): Count argument is now size_t *, not int *.
	(dfastate): State numbers are now ptrdiff_t, not int.
	* src/dfasearch.c: Include "intprops.h", for TYPE_MAXIMUM.
	(kwset_exact_matches): Now size_t, not int.
	(EGexecute): Don't assume indexes fit in 'int'.
	Check for overflow before converting a ptrdiff_t to a regoff_t,
	as regoff_t is narrower than ptrdiff_t in 64-bit glibc (contra POSIX).
	Check for memory exhaustion in re_search rather than treating
	it merely as failure to match; use xalloc_die () to report any error.
	* src/kwset.c (struct trie.accepting): Now size_t, not unsigned int.
	(struct kwset.words): Now ptrdiff_t, not int.
	* src/kwset.h (struct kwsmatch.index): Now size_t, not int.

	tests: test for problems with long matches
	The new test is expensive, so add a category of expensive tests,
	which are normally not run, and put the new test in this new
	category.  The idea of having expensive tests is taken from coreutils.
	* HACKING: Mention RUN_EXPENSIVE_TESTS and similar env vars.
	* Makefile.am (check-expensive): New rule.
	* tests/Makefile.am (TESTS): Add big-match.
	* tests/init.cfg (expensive_): New function, from coreutils.
	* tests/big-match: New file.

2012-02-29  Paul Eggert  <eggert@cs.ucla.edu>

	maint: use gnulib _Noreturn rather than __attribute__ ((noreturn))
	* src/grep.h (__attribute__): Remove.
	* src/dfa.h (__attribute__): Likewise.
	(dfaerror): Use noreturn rather than __attribute__ ((noreturn)).
	* src/main.c (usage): Likewise.

2012-02-26  Jim Meyering  <meyering@redhat.com>

	build: update submodule, bootstrap, tests/init.sh from gnulib
	* gl/lib/regcomp.c.diff: Adjust.
	* bootstrap: Update from gnulib.
	* tests/init.sh: Update from gnulib.

2012-02-26  Paolo Bonzini  <bonzini@gnu.org>

	dfa: merge calls to SUCCEEDS_IN_CONTEXT
	* src/dfa.c (state_index): use a single call to SUCCEEDS_IN_CONTEXT.

	dfa: fix a subtle constraint encoding bug
	* src/dfa.c (SUCCEEDS_IN_CONTEXT, PREV_NEWLINE_DEPENDENT,
	PREV_LETTER_DEPENDENT): Rewrite to handle all 3*3=9 possible
	combinations of previous and next character contexts.
	(MATCHES_NEWLINE_CONTEXT, MATCHES_LETTER_CONTEXT): Remove.
	(NO_CONSTRAINT, BEGLINE_CONSTRAINT, ENDLINE_CONSTRAINT,
	BEGWORD_CONSTRAINT, ENDWORD_CONSTRAINT, LIMWORD_CONSTRAINT,
	NOTLIMWORD_CONSTRAINT): Switch to new encoding.
	* NEWS: Document resulting bugfix.
	* tests/spencer1.tests: Add regression test.

	dfa: do not use MATCHES_*_CONTEXT directly
	* src/dfa.c (dfastate): Use SUCCEEDS_IN_CONTEXT.

	dfa: change meaning of a state context
	* src/dfa.c (MATCHES_NEWLINE_CONTEXT, MATCHES_LETTER_CONTEXT): New.
	(state_separate_contexts): Remove second argument.
	(state_index): Do not mask away CTX_NONE.
	(dfaanalyze): Adjust call to state_index and state_separate_contexts.
	(dfastate): Adjust calls to state_index and state_separate_contexts.

2012-02-13  Paul Eggert  <eggert@cs.ucla.edu>

	tests: fix loop in epipe test
	* tests/epipe: Don't loop forever if the bug is present.
	Problem reported by Jaroslav Skarvada.

2012-02-08  Paul Eggert  <eggert@cs.ucla.edu>

	tests: work portably even if SIGPIPE is ignored
	* tests/epipe: Don't rely on "trap - PIPE"; that's not portable.
	Problem reported by Eric Blake in
	<http://lists.gnu.org/archive/html/bug-grep/2012-02/msg00017.html>.
	Also, use "ls -al" rather than "echo", in case "echo" is done by a
	buggy shell that ignores write errors.  And close grep's fd 3, as
	a sanity check.

	tests: work even if SIGPIPE is ignored
	* tests/epipe: Do not infinite-loop if SIGPIPE is already ignored.
	It could be that the invoker of 'make check' ignores SIGPIPE,
	for example.

2012-02-05  Jim Meyering  <meyering@redhat.com>

	build: accommodate -Wshadow and -Werror=suggest-attribute=pure
	* src/dfa.c (state_separate_contexts): Add _GL_ATTRIBUTE_PURE.
	(dfaexec): Rename parameter, s/newline/allow_nl/, to avoid
	shadowing the global.

2012-02-05  Paolo Bonzini  <bonzini@gnu.org>

	dfa: refactor common context computations
	* src/dfa.c (CTX_ANY, charclass_context, state_separate_contexts): New.
	(dfaanalyze): Use state_separate_contexts.
	(dfastate): Use charclass_context and state_separate_contexts.  Rename
	prev_context to separate_contexts.

	dfa: change newline/letter to a single context value
	* src/dfa.c (MATCHES_NEWLINE_CONTEXT, MATCHES_LETTER_CONTEXT,
	SUCCEEDS_IN_CONTEXT, ACCEPTS_IN_CONTEXT): Take a single context value
	for prev and curr.
	(struct dfa_state): Replace newline and letter with context.
	(wchar_context): New.
	(state_index): Replace newline and letter with context.  Compare
	context values in the state struct.  Adjust calls to pass contexts.
	(wants_newline): Replace with wanted_context.  Adjust calls to pass
	contexts.
	(dfastate): Replace wants_newline and wants_letter with wanted_context.
	Adjust calls to pass contexts.
	(build_state): Adjust calls to pass contexts.
	(match_anychar, match_mb_charset, transit_state): Use wchar_context.
	Adjust calls to pass contexts.

2012-02-05  Paolo Bonzini  <bonzini@gnu.org>

	dfa: introduce contexts for the values in d->success
	Also initialize all tables in a single place in dfasyntax.

	* src/dfa.c (CTX_NONE, CTX_LETTER, CTX_NEWLINE, char_context): New.
	(sbit, letters, newline): New.
	(dfasyntax): Fill them.
	(dfastate): Remove letters, newline, initialized.
	(build_state): Use CTX_* constants.
	(dfaexec): Remove sbit and sbit_init.

2012-02-05  Paolo Bonzini  <bonzini@gnu.org>

	dfa: remove useless check
	* src/dfa.c (state_index): There is nothing that is a newline *and*
	a letter.  Remove redundant call to SUCCEEDS_IN_CONTEXT.

2012-01-22  Jim Meyering  <meyering@redhat.com>

	build: update bootstrap from gnulib and adapt
	* bootstrap: Update from gnulib.
	* tests/init.sh: Update from gnulib.
	* bootstrap.conf (bootstrap_epilogue): Remove now-unnecessary,
	snippet that edited gnulib-tests/gnulib.mk.
	(gnulib_tool_option_extras): Add both --symlink and
	--makefile-name=gnulib.mk.  Remove use of $bt.
	* lib/Makefile.am: Initialize numerous automake variables so that
	generated code in gnulib.mk may use += to append to them.

	maint: convert `this' to 'this' quoting style in diagnostics
	Now that gnulib's quote and quotearg modules use 'this' style,
	change the few explicit uses in diagnostics to conform.
	* src/egrep.c (after_options): Use 'this' style of quotes.
	* src/fgrep.c (after_options): Likewise.
	* src/grep.c (after_options): Likewise.
	* src/main.c (usage): Likewise.

	build: update gnulib to latest; adjust quoting in tests
	* gnulib: Update.
	* tests/in-eq-out-infloop: Convert expected diagnostics to match
	new quoting.

2012-01-22  Paul Eggert  <eggert@cs.ucla.edu>

	doc: document recent diagnostics-related changes
	* NEWS: Document changes re diagnostics related to GREP_COLORS,
	directory loops, -s, "write error".

	grep: be quiet about GREP_COLORS syntax
	* src/main.c (struct color_cap): fct now returns void,
	since there's no longer need to use what it returns.
	(color_cap_mt_fct, color_cap_rv_fct, color_cap_ne_fct): Return void.
	(parse_grep_colors): Do not output diagnostics and then exit with
	status 0.  Instead, ignore errors in GREP_COLORS.  This is more
	consistent with programs that (e.g.) ignore errors in termcap entries,
	and it's more internally-consistent as some GREP_COLORS errors
	were ignored but not others.

	grep: exit with nonzero status if directory loop
	* src/main.c (grepdir): Exit with status 2 if a directory loop is
	found, since the output might not be "right" (i.e., infinite...).

	grep: suppress read errors if -s
	* src/main.c (reset, grep, grepfile): Do not report an input error
	if -s is given.

	grep: don't say "write error" over and over
	Problem reported by Travis Gummels in
	<https://bugzilla.redhat.com/show_bug.cgi?id=741452>.
	* src/main.c (write_error_seen): New static var.
	(clean_up_stdout): New function.
	(prline): Do not output 'write error' more than once; exit
	after the first one.  Use the same wording for the diagnostic
	that close_stdout uses.
	(main): Clean up with clean_up_stdout, not close_stdout, so that
	grep doesn't output multiple "write error" diagnostics.
	* tests/Makefile.am (TESTS): Add epipe.
	* tests/epipe: New file.

2012-01-12  Paul Eggert  <eggert@cs.ucla.edu>

	dfa: non-glibc word-constituent unibyte fix
	* src/dfa.c (is_valid_unibyte_character): Fix typo that caused
	this to incorrectly return 0 on unibyte non-glibc systems.
	Problem reported by Aharon Robbins in
	<http://lists.gnu.org/archive/html/bug-grep/2012-01/msg00084.html>.

2012-01-04  Paul Eggert  <eggert@cs.ucla.edu>

	doc: document empty pattern better
	* doc/grep.texi (Top, Fundamental Structure, Usage):
	Explain how grep deals with the empty pattern.
	Problem spotted by Bernhard Voelker in
	<http://lists.gnu.org/archive/html/bug-grep/2012-01/msg00050.html>.

	grep: with no args, search "." only if command-line -r
	* NEWS: Document this.
	* doc/grep.texi (Environment Variables, grep Programs): Likewise.
	* src/main.c (usage): Likewise.
	(main): Implement this.
	(prepend_default_options): Return a count of prepended options.
	* tests/r-dot: Test the above.

2012-01-03  Jim Meyering  <meyering@redhat.com>

	tests: adjust test to match code, now that --mmap writes to stderr
	* tests/ignore-mmap: Separate stdout and stderr; test both.

	deprecate the --mmap option
	* src/main.c (main): Deprecate the --mmap option: issue a warning
	when it is used.
	(usage): Change description.
	* doc/grep.texi (Other Options): Document the new behavior.
	* NEWS (Changes in behavior): Mention it.

2012-01-03  Paolo Bonzini  <bonzini@gnu.org>

	dfa: fix incorrect comment
	* src/dfa.c (dfastate): Fix comment for newline.

	dfa: fix rebase conflict
	* src/dfa.c (dfaanalyze): Fix reference to nalloc.

	dfa: automatically resize position_sets
	* src/dfa.c (insert, copy, merge): Resize arrays here.
	(dfaanalyze): Do not track number of allocated elements here.
	(dfastate): Allocate mbps with only one element.

	dfa: change position_set nelem to size_t
	* src/dfa.c (REALLOC_IF_NECESSARY): Disable assertion, to avoid
	warnings from -Wtype-limits.
	(position_set): Change nelem to a size_t.

	dfa: move nalloc to position_set structure
	* src/dfa.c (position_set): Add alloc.
	(alloc_position_set): Initialize it.
	(dfaanalyze): Use it instead of the nalloc array or nelem.

	dfa: remove dead assignment
	* src/dfa.c (transit_state): transit_state_consume_1char will clear follows,
	do not do this ourselves.

	dfa: introduce alloc_position_set
	* src/dfa.c (alloc_position_set): New function, use it throughout.

	dfa: use a more compact data type for grps
	* src/dfa.c (leaf_set): New.
	(dfastate): Use the smaller type, leaf_set, for grps.  Its prior type
	contained an unused constraint field.

	dfa: use MALLOC/REALLOC always
	src/dfa.c (dfastate, enlist, dfamust): Use MALLOC and REALLOC.

	dfa: remove unnecessary braces
	* src/dfa.c (dfastate): Remove unnecessary braces.

	dfa: x2nrealloc starting from a NULL pointer works
	* src/dfa.c (parse_bracket_exp): Do not MALLOC mbcset parts the first time
	they are encountered.  Initialize chars_al correctly.

2012-01-03  Jim Meyering  <meyering@redhat.com>

	build: avoid build failure with --enable-gcc-warnings and recent gcc
	* lib/colorize-posix.c: Disable -Wsuggest-attribute=const, to avoid
	warning about this empty init_colorize function.

2012-01-03  Paolo Bonzini  <bonzini@gnu.org>

	remove lib/ms/
	* configure.ac: Create lib/colorize.c as a symbolic link.
	* lib/colorize-posix.c: New name of lib/colorize-impl.c.
	* lib/colorize-w32.c: New name of lib/ms/colorize-impl.c.
	* lib/colorize.c: Delete.
	* lib/Makefile.am (EXTRA_DIST): Adjust.
	* .gitignore: Adjust.
	* cfg.mk: Adjust syntax-check exclusions.

	unify colorize.h headers
	* lib/Makefile.am (EXTRA_DIST): Adjust.
	* lib/colorize.h: Remove inline functions.
	* lib/colorize-impl.c: Move them here as functions.
	* lib/ms/colorize.h: Remove.
	* src/Makefile.am (DEFAULT_HEADERS): Remove.

	colorize: use isatty module
	* bootstrap.conf: Add isatty module.
	* gnulib: Update to latest.
	* lib/colorize.h: Remove argument from should_colorize.
	* lib/ms/colorize.h: Likewise.
	* lib/colorize-impl.c: Factor isatty call out of here...
	* lib/ms/colorize-impl.c: ... and here...
	* src/main.c: ... into here.

2012-01-03  Jim Meyering  <meyering@redhat.com>

	tests: avoid minor "make check" failure
	* tests/r-dot: Make executable, to avoid triggering a failed
	consistency test in "make check".

2012-01-02  Paul Eggert  <eggert@cs.ucla.edu>

	grep: -r with no args now searches "."
	This is a patch I've been meaning to put in for years.
	When I added support for "grep -r", I forgot to have "grep -r PAT"
	search the working directory by default, instead of searching
	standard input (which makes no sense, even if stdin is a directory).
	This is not an upward compatible change, since "grep -r PAT <file"
	will no longer search standard input, but that's OK; nobody should
	be using "grep -r" that way anyway.
	* NEWS: Document this.
	* doc/grep.texi (File and Directory Selection, grep Programs, Usage):
	Likewise.
	* src/main.c (usage): Likewise.
	(grepdir): If DIR is null, search the working directory, but do
	not prepend "./" to the file names.
	(main): If recursing and no operands are given, search ".".
	* tests/Makefile.am (TESTS): Add r-dot.
	* tests/r-dot: New file.

	grep: prefer fgets to printf, _ to gettext
	* lib/colorize.h (print_end_colorize):
	* lib/ms/colorize-impl.c (print_end_colorize):
	Use fputs instead of printf.
	* src/main.c (usage): Likewise.  Use _ instead of gettext.

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

	grep: check stdin like other files
	* NEWS: Document this.
	* src/main.c (grepfile): Revamp tests for input files so that
	standard input is tested like other files.  For example, report
	an error if standard input equals standard output.
	Prefer open+fstat to stat+open if possible, as open+fstat is
	usually a bit faster and avoids a race condition.
	* tests/in-eq-out-infloop: Add tests for cases like
	'grep pat <file >>file'.

2012-01-01  Jim Meyering  <meyering@redhat.com>

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

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

	grep: lower-case function names
	These names used to be macros, but they're functions now.
	All callers changed.
	* src/main.c (pr_sgr_start): Rename from PR_SGR_START.
	(pr_sgr_end): Rename from PR_SGR_END.
	(pr_sgr_start_if): Rename from PR_SGR_START_IF.
	(pr_sgr_end_if): Rename from PR_SGR_END_IF.

	ms: move Microsoft-specific stuff to lib/ms
	* cfg.mk (exclude_file_name_regexp--sc_prohibit_strcmp)
	(exclude_file_name_regexp--sc_require_config_h)
	(exclude_file_name_regexp--sc_require_config_h_first):
	New rules.
	* lib/colorize.c, lib/colorize.h, lib/colorize-impl.c:
	* lib/ms/colorize.h, lib/ms/colorize-impl.c: New files.
	* configure.ac (GREP_SRC_INCLUDES): New macro.
[--snip--]
