Upgrade grep version 2.9 to 2.12 on the vendor branch
grep: remove local option --only-files permanently

The grep option --only-files exists only on DragonFly.  It was added in
late 2005 by Simon Schubert as a quick and dirty way to search object
directories using grep rather than a complex find command.  The issue
was that some directory symlinks were created that produced recursive
loops.  There wasn't a lot of support for the suggestion, but when the
code was altered to allow non-directory symlinks to be followed by the
--only-files option, the main objection was addressed.

The problem is that this modification is making it difficult to maintain
grep.  The code that it touches changes frequently, and its unmergable
with grep 2.12.  The burden of maintaining this option is too much
considering it may only have a single user.

Discussed with: Dillon

For the purposes of merging grep 2.12, the hammer bug fix is also being
removed since it doesn't merge cleanly, but it will be restored after
the merge.
Merge branch 'vendor/GREP'
grep: Upgrade from version 2.9 to 2.12

=====================   Version 2.10 (16 NOV 2011)   =====================

It's been nearly five months and 80 commits since 2.9, yet few big
changes in grep proper.  However, there have been many changes in gnulib,
including a few portability fixes that affect grep.   We inherited 750+
portability and robustness improvements by using gnulib.

[Bug fixes]
* grep no longer mishandles high-bit-set pattern bytes on systems
  where "char" is a signed type. [bug appears to affect only MS-Windows]

* grep now rejects a command like "grep -r pattern . > out",
  in which the output file is also one of the inputs,
  because it can result in an "infinite" disk-filling loop.
  [bug present since "the beginning"]

[Build-related]
  "make dist" no longer builds .tar.gz files.
  xz is portable enough and in wide-enough use that distributing
  only .tar.xz files is enough.

=====================   Version 2.11 (02 MAR 2012)   =====================

In just 2.5 months, we've seen more changes than in the five months
leading up to 2.10, addressing a surprising number of old bugs.
Special thanks to Paulo Bonzini and Paul Eggert for many fine patches.  We
inherited 340+ portability and robustness improvements by using gnulib.

[New features]
* If no file operand is given, and a command-line -r or equivalent
  option is given, grep now searches the working directory.  Formerly
  grep ignored the -r and searched standard input nonrecursively.
  An -r found in GREP_OPTIONS does not have this new effect.

* grep now supports color highlighting of matches on MS-Windows.

[Bug fixes]
* grep no longer dumps core on lines whose lengths do not fit in 'int'.
  (e.g., lines longer than 2 GiB on a typical 64-bit host).
  Instead, grep either works as expected, or reports an error.
  An error can occur if not enough main memory is available, or if the
  GNU C library's regular expression functions cannot handle such long
  lines. [bug present since "the beginning"]

* The -m, -A, -B, and -C options no longer mishandle context line
  counts that do not fit in 'int'.  Also, grep -c's counts are now
  limited by the type 'intmax_t' (typically less than 2**63) rather
  than 'int' (typically less than 2**31).

* grep no longer silently suppresses errors when reading a directory
  as if it were a text file.  For example, "grep x ." now reports a
  read error on most systems; formerly, it ignored the error.
  [bug introduced in grep-2.5]

* grep now exits with status 2 if a directory loop is found,
  instead of possibly exiting with status 0 or 1.
  [bug introduced in grep-2.3]

* The -s option now suppresses certain input error diagnostics that it
  formerly failed to suppress.  These include errors when closing the
  input, when lseeking the input, and when the input is also the output.
  [bug introduced in grep-2.4]

* On POSIX systems, commands like "grep PAT < FILE >> FILE"
  now report an error instead of looping.
  [bug present since "the beginning"]

* The --include, --exclude, and --exclude-dir options now handle
  command-line arguments more consistently.  --include and --exclude
  apply only to non-directories and --exclude-dir applies only to
  directories.  "-" (standard input) is never excluded, since it is
  not a file name.
  [bug introduced in grep-2.5]

* grep no longer rejects "grep -qr . > out", i.e., when run with -q
  and an input file is the same as the output file, since with -q
  grep generates no output, so there is no risk of infinite loop or
  of an output-affecting race condition.  Thus, the use of the following
  options also disables the input-equals-output failure:
    --max-count=N (-m) (for N >= 2)
    --files-with-matches (-l)
    --files-without-match (-L)
  [bug introduced in grep-2.10]

* grep no longer emits an error message and quits on MS-Windows when
  invoked with the -r option.

* grep no longer misinterprets some alternations involving anchors
  (^, $, \<  \>  \B, \b).  For example, grep -E "(^|\B)a" no
  longer reports a match for the string "x a".
  [bug present since "the beginning"]

[Changes in behavior]
* Use of the --mmap option now elicits a warning.  It has been a no-op
  since March of 2010.

* grep no longer diagnoses write errors repeatedly; it exits after
  diagnosing the first write error.  This is better behavior when
  writing to a dangling pipe.

* Syntax errors in GREP_COLORS are now ignored, instead of sometimes
  eliciting warnings.  This is more consistent with programs that
  (e.g.) ignore errors in termcap entries.

=====================   Version 2.12 (23 APR 2012)   =====================

There have been 22 commits by 3 people in the 7 weeks since 2.11.
In spite of the relatively small number of commits, this is a
significant delta, with two regression fixes, Paul's conversion,
from grep's crufty old dir-traversal code to the use of gnulib's fts
and the change to how -r (--recursive) works.

[Bug fixes]
* "echo P|grep --devices=skip P" once again prints P, as it did in 2.10
  [bug introduced in grep-2.11]

* grep no longer segfaults with -r --exclude-dir and no file operand.
  I.e., ":|grep -r --exclude-dir=D PAT" would segfault.
  [bug introduced in grep-2.11]

* Recursive grep now uses fts for directory traversal, so it can
  handle much-larger directories without reporting things like "File
  name too long", and it can run much faster when dealing with large
  directory hierarchies. [bug present since the beginning]

* grep -E 'a{1000000000}' now reports an overflow error rather than
  silently acting like grep -E 'a\{1000000000}'.

[New features]
* The -R option now has a long-option alias --dereference-recursive.

[Changes in behavior]
* The -r (--recursive) option now follows only command-line symlinks.
  Also, by default -r now reads a device only if it is named on the
  command line; this can be overridden with --devices.  -R acts as
  before, so use -R if you prefer the old behavior of following all
  symlinks and defaulting to reading all devices.
grep: Restore modification for HAMMER FS

The first version of this modification was created by Matthias Schmidt.
Unmodified, grep used on a HAMMER filesystem will emit "Invalid argument"
when scanning directories because HAMMER doesn't treat them as files.

Unmodified behavior:
> cd /usr/src
> grep test: *
Makefile:test:
grep: cat: Invalid argument
[...]

After modification:
> cd /usr/src
> grep test: *
Makefile:test:

The modification was removed because it didn't merge simply with the
grep upgrade from 2.9 to 2.12.  Now that the merge is complete, the
new version of the modification is applied to restore the correct
behavior of grep on the HAMMER filesystem.