Fix regexp parsing with RE_CONTEXT_INDEP_OPS

Andreas Schwab schwab@suse.de
Sat Dec 13 09:56:00 GMT 2003


When parsed with RE_SYNTAX_EGREP (which includes RE_CONTEXT_INDEP_OPS)
the regexp "(*)b" results in the error "unmatched ) or \)", but it
should compile successfully (treating it as if "()b").  This is part
of the Spencer tests in grep.

Andreas.

2003-12-13  Andreas Schwab  <schwab@suse.de>

	* posix/regcomp.c (parse_expression): Don't recurse when the end
	of a subexp is seen after a repetition operator with
	RE_CONTEXT_INVALID_DUP.

--- posix/regcomp.c.~1.67.~	2003-11-30 00:08:06.000000000 +0100
+++ posix/regcomp.c	2003-12-13 09:59:26.000000000 +0100
@@ -2191,6 +2191,8 @@ parse_expression (regexp, preg, token, s
       else if (syntax & RE_CONTEXT_INDEP_OPS)
 	{
 	  fetch_token (token, regexp, syntax);
+	  if (token->type == OP_CLOSE_SUBEXP || token->type == OP_ALT)
+	    return NULL;
 	  return parse_expression (regexp, preg, token, syntax, nest, err);
 	}
       /* else fall through  */

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



More information about the Libc-hacker mailing list