]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
bsdgrep: add a primitive literal matcher to unbreak fgrep in some scenarios
authorkevans <kevans@FreeBSD.org>
Mon, 11 Sep 2017 15:52:24 +0000 (15:52 +0000)
committerkevans <kevans@FreeBSD.org>
Mon, 11 Sep 2017 15:52:24 +0000 (15:52 +0000)
commitf1f01794675bbb08bbb5e7b46e94cdfa850833b1
tree492a0c6a67533a7ec3f4983a407d06496c3289d2
parent7bb4af013bfb33afc54e662f105065877842b109
bsdgrep: add a primitive literal matcher to unbreak fgrep in some scenarios

MFC r322825: bsdgrep: add some additional tests for fgrep

Previously added tests only check that fgrep is somewhat sane and works. Add
some more tests that check that the implementation is basically functional
and not producing incorrect results with various flags.

MFC r322826: bsdgrep: add a primitive literal matcher

fgrep/grep -F will error out at runtime if compiled with a regex(3)
that does not define REG_NOSPEC or REG_LITERAL. glibc is one such regex(3)
implementation, and as it turns out they don't support literal matching at
all.

Provide a primitive literal matcher for use with glibc and other
implementations that don't support literal matching so that we don't
completely lose fgrep/grep -F if compiled against libgnuregex on stable/10,
stable/11, or other systems that we don't necessarily support.

This is a wholly unoptimized implementation with no plans to optimize it as
of now. This is due to both its use-case being primarily on unsupported
systems in the near-distant future and that it's reinventing the wheel that
we already have available as a feature of regex(3).

PR: 222201
Approved by: emaste (mentor, blanket MFC)
contrib/netbsd-tests/usr.bin/grep/t_grep.sh
usr.bin/grep/grep.c
usr.bin/grep/grep.h
usr.bin/grep/util.c