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.