提交 25160f1c 编写于 作者: S Szabolcs Nagy 提交者: Rich Felker

regex: treat \+, \? as repetitions in BRE

These are undefined escape sequences by the standard, but often
used in sed scripts.
上级 03498ec2
...@@ -838,6 +838,9 @@ static reg_errcode_t parse_atom(tre_parse_ctx_t *ctx, const char *s) ...@@ -838,6 +838,9 @@ static reg_errcode_t parse_atom(tre_parse_ctx_t *ctx, const char *s)
s--; s--;
break; break;
case '{': case '{':
case '+':
case '?':
/* extension: treat \+, \? as repetitions in BRE */
/* reject repetitions after empty expression in BRE */ /* reject repetitions after empty expression in BRE */
if (!ere) if (!ere)
return REG_BADRPT; return REG_BADRPT;
...@@ -993,7 +996,8 @@ static reg_errcode_t tre_parse(tre_parse_ctx_t *ctx) ...@@ -993,7 +996,8 @@ static reg_errcode_t tre_parse(tre_parse_ctx_t *ctx)
} }
if (*s=='\\' && ere) if (*s=='\\' && ere)
break; break;
if (*s=='\\' && s[1]!='{') /* extension: treat \+, \? as repetitions in BRE */
if (*s=='\\' && s[1]!='+' && s[1]!='?' && s[1]!='{')
break; break;
if (*s=='\\') if (*s=='\\')
s++; s++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册