@@ -965,7 +965,8 @@ enum error_type
965
965
error_stack,
966
966
__re_err_grammar,
967
967
__re_err_empty,
968
- __re_err_unknown
968
+ __re_err_unknown,
969
+ __re_err_parse
969
970
};
970
971
971
972
} // regex_constants
@@ -2539,17 +2540,15 @@ public:
2539
2540
: __flags_(__f), __marked_count_(0 ), __loop_count_(0 ), __open_count_(0 ),
2540
2541
__end_(0 )
2541
2542
{
2542
- if (__get_grammar (__flags_) == 0 ) __flags_ |= regex_constants::ECMAScript;
2543
- __parse (__p, __p + __traits_.length (__p));
2543
+ __init (__p, __p + __traits_.length (__p));
2544
2544
}
2545
2545
2546
2546
_LIBCPP_INLINE_VISIBILITY
2547
2547
basic_regex (const value_type* __p, size_t __len, flag_type __f = regex_constants::ECMAScript)
2548
2548
: __flags_(__f), __marked_count_(0 ), __loop_count_(0 ), __open_count_(0 ),
2549
2549
__end_(0 )
2550
2550
{
2551
- if (__get_grammar (__flags_) == 0 ) __flags_ |= regex_constants::ECMAScript;
2552
- __parse (__p, __p + __len);
2551
+ __init (__p, __p + __len);
2553
2552
}
2554
2553
2555
2554
// basic_regex(const basic_regex&) = default;
@@ -2561,8 +2560,7 @@ public:
2561
2560
: __flags_(__f), __marked_count_(0 ), __loop_count_(0 ), __open_count_(0 ),
2562
2561
__end_(0 )
2563
2562
{
2564
- if (__get_grammar (__flags_) == 0 ) __flags_ |= regex_constants::ECMAScript;
2565
- __parse (__p.begin (), __p.end ());
2563
+ __init (__p.begin (), __p.end ());
2566
2564
}
2567
2565
2568
2566
template <class _ForwardIterator >
@@ -2572,8 +2570,7 @@ public:
2572
2570
: __flags_(__f), __marked_count_(0 ), __loop_count_(0 ), __open_count_(0 ),
2573
2571
__end_(0 )
2574
2572
{
2575
- if (__get_grammar (__flags_) == 0 ) __flags_ |= regex_constants::ECMAScript;
2576
- __parse (__first, __last);
2573
+ __init (__first, __last);
2577
2574
}
2578
2575
#ifndef _LIBCPP_CXX03_LANG
2579
2576
_LIBCPP_INLINE_VISIBILITY
@@ -2582,8 +2579,7 @@ public:
2582
2579
: __flags_(__f), __marked_count_(0 ), __loop_count_(0 ), __open_count_(0 ),
2583
2580
__end_(0 )
2584
2581
{
2585
- if (__get_grammar (__flags_) == 0 ) __flags_ |= regex_constants::ECMAScript;
2586
- __parse (__il.begin (), __il.end ());
2582
+ __init (__il.begin (), __il.end ());
2587
2583
}
2588
2584
#endif // _LIBCPP_CXX03_LANG
2589
2585
@@ -2698,6 +2694,9 @@ private:
2698
2694
_LIBCPP_INLINE_VISIBILITY
2699
2695
unsigned __loop_count () const {return __loop_count_;}
2700
2696
2697
+ template <class _ForwardIterator >
2698
+ void
2699
+ __init (_ForwardIterator __first, _ForwardIterator __last);
2701
2700
template <class _ForwardIterator >
2702
2701
_ForwardIterator
2703
2702
__parse (_ForwardIterator __first, _ForwardIterator __last);
@@ -3054,6 +3053,17 @@ __lookahead<_CharT, _Traits>::__exec(__state& __s) const
3054
3053
}
3055
3054
}
3056
3055
3056
+ template <class _CharT , class _Traits >
3057
+ template <class _ForwardIterator >
3058
+ void
3059
+ basic_regex<_CharT, _Traits>::__init(_ForwardIterator __first, _ForwardIterator __last)
3060
+ {
3061
+ if (__get_grammar (__flags_) == 0 ) __flags_ |= regex_constants::ECMAScript;
3062
+ _ForwardIterator __temp = __parse (__first, __last);
3063
+ if ( __temp != __last)
3064
+ __throw_regex_error<regex_constants::__re_err_parse>();
3065
+ }
3066
+
3057
3067
template <class _CharT , class _Traits >
3058
3068
template <class _ForwardIterator >
3059
3069
_ForwardIterator
0 commit comments