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.

Reported by: antoine

Reported by:	antoine
Approved by:	emaste (mentor)
Differential Revision:	https://reviews.freebsd.org/D11522
This commit is contained in:
Kyle Evans 2017-07-07 22:00:39 +00:00
parent bbbfb2a922
commit 79c9a695c3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=320796

View File

@ -672,7 +672,7 @@ p_re(struct parse *p,
bc.terminate = false;
if (p->pre_parse != NULL)
p->pre_parse(p, &bc);
while (MORE() && !SEESPEC('|') && !SEEEND()) {
while (MORE() && (!p->allowbranch || !SEESPEC('|')) && !SEEEND()) {
bc.terminate = p->parse_expr(p, &bc);
++bc.nchain;
}