nosubs = 1 << 1,
optimize = 1 << 2,
collate = 1 << 3,
+#ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
+ ECMAScript = 1 << 9,
+#else
ECMAScript = 0,
+#endif
basic = 1 << 4,
extended = 1 << 5,
awk = 1 << 6,
egrep = 1 << 8
};
+inline _LIBCPP_CONSTEXPR
+syntax_option_type __get_grammar(syntax_option_type __g)
+{
+#ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
+ return static_cast<syntax_option_type>(__g & 0x3F0);
+#else
+ return static_cast<syntax_option_type>(__g & 0x1F0);
+#endif
+}
+
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR
syntax_option_type
// construct/copy/destroy:
_LIBCPP_INLINE_VISIBILITY
basic_regex()
- : __flags_(), __marked_count_(0), __loop_count_(0), __open_count_(0),
+ : __flags_(regex_constants::ECMAScript), __marked_count_(0), __loop_count_(0), __open_count_(0),
__end_(0)
{}
_LIBCPP_INLINE_VISIBILITY
explicit basic_regex(const value_type* __p, flag_type __f = regex_constants::ECMAScript)
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
__end_(0)
- {__parse(__p, __p + __traits_.length(__p));}
+ {
+ if (__get_grammar(__flags_) == 0) __flags_ |= regex_constants::ECMAScript;
+ __parse(__p, __p + __traits_.length(__p));
+ }
+
_LIBCPP_INLINE_VISIBILITY
basic_regex(const value_type* __p, size_t __len, flag_type __f = regex_constants::ECMAScript)
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
__end_(0)
- {__parse(__p, __p + __len);}
+ {
+ if (__get_grammar(__flags_) == 0) __flags_ |= regex_constants::ECMAScript;
+ __parse(__p, __p + __len);
+ }
+
// basic_regex(const basic_regex&) = default;
// basic_regex(basic_regex&&) = default;
template <class _ST, class _SA>
flag_type __f = regex_constants::ECMAScript)
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
__end_(0)
- {__parse(__p.begin(), __p.end());}
+ {
+ if (__get_grammar(__flags_) == 0) __flags_ |= regex_constants::ECMAScript;
+ __parse(__p.begin(), __p.end());
+ }
+
template <class _ForwardIterator>
_LIBCPP_INLINE_VISIBILITY
basic_regex(_ForwardIterator __first, _ForwardIterator __last,
flag_type __f = regex_constants::ECMAScript)
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
__end_(0)
- {__parse(__first, __last);}
+ {
+ if (__get_grammar(__flags_) == 0) __flags_ |= regex_constants::ECMAScript;
+ __parse(__first, __last);
+ }
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
basic_regex(initializer_list<value_type> __il,
flag_type __f = regex_constants::ECMAScript)
: __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
__end_(0)
- {__parse(__il.begin(), __il.end());}
+ {
+ if (__get_grammar(__flags_) == 0) __flags_ |= regex_constants::ECMAScript;
+ __parse(__il.begin(), __il.end());
+ }
#endif // _LIBCPP_CXX03_LANG
// ~basic_regex() = default;
__h.release();
__end_ = __start_.get();
}
- switch (__flags_ & 0x1F0)
+ switch (__get_grammar(__flags_))
{
case ECMAScript:
__first = __parse_ecma_exp(__first, __last);
__first = ++__temp;
break;
default:
- if ((__flags_ & 0x1F0) == awk)
+ if (__get_grammar(__flags_) == awk)
__first = __parse_awk_escape(++__first, __last);
break;
}
{
if (__first != __last)
{
- unsigned __grammar = __flags_ & 0x1F0;
+ unsigned __grammar = __get_grammar(__flags_);
switch (*__first)
{
case '*':
// __ml owned by *this
if (__first == __last)
__throw_regex_error<regex_constants::error_brack>();
- if ((__flags_ & 0x1F0) != ECMAScript && *__first == ']')
+ if (__get_grammar(__flags_) != ECMAScript && *__first == ']')
{
__ml->__add_char(']');
++__first;
else if (*__temp == '.')
__first = __parse_collating_symbol(++__temp, __last, __start_range);
}
- unsigned __grammar = __flags_ & 0x1F0;
+ unsigned __grammar = __get_grammar(__flags_);
if (__start_range.empty())
{
if ((__grammar == ECMAScript || __grammar == awk) && *__first == '\\')
match_results<const _CharT*, _Allocator>& __m,
regex_constants::match_flag_type __flags, bool __at_first) const
{
- if ((__flags_ & 0x1F0) == ECMAScript)
+ if (__get_grammar(__flags_) == ECMAScript)
return __match_at_start_ecma(__first, __last, __m, __flags, __at_first);
if (mark_count() == 0)
return __match_at_start_posix_nosubs(__first, __last, __m, __flags, __at_first);