fix parse bug in ecma non-greedy loop
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@109711 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/regex b/include/regex
index 0bafbcf..519c723 100644
--- a/include/regex
+++ b/include/regex
@@ -3423,11 +3423,12 @@
{
if (__first != __last)
{
+ unsigned __grammar = __flags_ & 0x1F0;
switch (*__first)
{
case '*':
++__first;
- if ((__flags_ & ECMAScript) && __first != __last && *__first == '?')
+ if (__grammar == ECMAScript && __first != __last && *__first == '?')
{
++__first;
__push_nongreedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
@@ -3437,7 +3438,7 @@
break;
case '+':
++__first;
- if ((__flags_ & ECMAScript) && __first != __last && *__first == '?')
+ if (__grammar == ECMAScript && __first != __last && *__first == '?')
{
++__first;
__push_nongreedy_inf_repeat(1, __s, __mexp_begin, __mexp_end);
@@ -3447,7 +3448,7 @@
break;
case '?':
++__first;
- if ((__flags_ & ECMAScript) && __first != __last && *__first == '?')
+ if (__grammar == ECMAScript && __first != __last && *__first == '?')
{
++__first;
__push_loop(0, 1, __s, __mexp_begin, __mexp_end, false);
@@ -3468,7 +3469,7 @@
{
case '}':
++__first;
- if ((__flags_ & ECMAScript) && __first != __last && *__first == '?')
+ if (__grammar == ECMAScript && __first != __last && *__first == '?')
{
++__first;
__push_loop(__min, __min, __s, __mexp_begin, __mexp_end, false);
@@ -3482,7 +3483,7 @@
if (*__first == '}')
{
++__first;
- if ((__flags_ & ECMAScript) && __first != __last && *__first == '?')
+ if (__grammar == ECMAScript && __first != __last && *__first == '?')
{
++__first;
__push_nongreedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
@@ -3502,7 +3503,7 @@
++__first;
if (__max < __min)
throw regex_error(regex_constants::error_badbrace);
- if ((__flags_ & ECMAScript) && __first != __last && *__first == '?')
+ if (__grammar == ECMAScript && __first != __last && *__first == '?')
{
++__first;
__push_loop(__min, __max, __s, __mexp_begin, __mexp_end, false);