]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r320742, r320750, r320796: Refactor regex(3) for maintainability
authorkevans <kevans@FreeBSD.org>
Thu, 18 Jan 2018 22:10:00 +0000 (22:10 +0000)
committerkevans <kevans@FreeBSD.org>
Thu, 18 Jan 2018 22:10:00 +0000 (22:10 +0000)
commit59d04d9396d6ca2f06abbde724cd61bbd9049d47
tree0b8cf203f5366a2b2fa677e825fd45a94e783fa5
parent95b8f69ef3baf8a9b45e0963cecac957b54eb93c
MFC r320742, r320750, r320796: Refactor regex(3) for maintainability

MFC r320742:
The impending libregex will implement GNU extensions to bring BREs and
EREs closer together. Prepare for this and reduce the diff of libregex
changes by refactoring and combining the top-level parsers for EREs/BREs
ahead of time.

Branching functionality has been split out to make it easier to follow the
combined version of the top-level parser. It may also be enabled in the
parsing context to make it easier when libregex enables branching for BREs.

A branching context was also added for the various branching functions and
so that BREs, for instance, can determine if they're the first expression in
a chain of expressions within the current branch and treat '*' as ordinary
if so.

This should have no functional impact and negligible performance impact.

MFC r320750: Fix sparc64 libc build after r320742.

p_branch_empty was declared but never used due to an oversight. Use it as
designed, further comment on its return value.

MFC r320796:
Correctly ignore branch operators in the top-level parser when applicable.

An oversight in r320742 caused BREs to become sensitive to the branching
operator prematurely, which caused breakage in some limited situations --
namely, those that tried to use branching in a BRE. Most of these scenarios
had already been corrected beforehand to properly use gsed or grep for GNU
extensions, so the damage is slightly mitigated.
lib/libc/regex/regcomp.c
lib/libc/regex/regex2.h