diff options
author | 2018-09-11 18:18:58 +0000 | |
---|---|---|
committer | 2018-09-11 18:18:58 +0000 | |
commit | 820e1f31efc1d6ed04795ba2e79f3044e1907492 (patch) | |
tree | 815cebb3734784074b661935c33f00bd5eb4d862 /lib/libcxx/include/regex | |
parent | Nuke unused LIST() ieee80211com_head. (diff) | |
download | wireguard-openbsd-820e1f31efc1d6ed04795ba2e79f3044e1907492.tar.xz wireguard-openbsd-820e1f31efc1d6ed04795ba2e79f3044e1907492.zip |
import of libc++ 6.0.0
Diffstat (limited to 'lib/libcxx/include/regex')
-rw-r--r-- | lib/libcxx/include/regex | 288 |
1 files changed, 185 insertions, 103 deletions
diff --git a/lib/libcxx/include/regex b/lib/libcxx/include/regex index 1139d8fb2a9..ff84b2738b7 100644 --- a/lib/libcxx/include/regex +++ b/lib/libcxx/include/regex @@ -127,6 +127,8 @@ class basic_regex public: // types: typedef charT value_type; + typedef traits traits_type; + typedef typename traits::string_type string_type; typedef regex_constants::syntax_option_type flag_type; typedef typename traits::locale_type locale_type; @@ -145,7 +147,7 @@ public: // construct/copy/destroy: basic_regex(); explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript); - basic_regex(const charT* p, size_t len, flag_type f); + basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript); basic_regex(const basic_regex&); basic_regex(basic_regex&&) noexcept; template <class ST, class SA> @@ -762,14 +764,17 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; #include <memory> #include <vector> #include <deque> -#include <cassert> - -#include <__undef_min_max> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + +#define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096 + _LIBCPP_BEGIN_NAMESPACE_STD namespace regex_constants @@ -864,7 +869,8 @@ enum match_flag_type format_sed = 1 << 8, format_no_copy = 1 << 9, format_first_only = 1 << 10, - __no_update_pos = 1 << 11 + __no_update_pos = 1 << 11, + __full_match = 1 << 12 }; inline _LIBCPP_INLINE_VISIBILITY @@ -957,18 +963,18 @@ public: }; template <regex_constants::error_type _Ev> -_LIBCPP_ALWAYS_INLINE +_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE void __throw_regex_error() { #ifndef _LIBCPP_NO_EXCEPTIONS throw regex_error(_Ev); #else - assert(!"regex_error"); + _VSTD::abort(); #endif } template <class _CharT> -struct _LIBCPP_TYPE_VIS_ONLY regex_traits +struct _LIBCPP_TEMPLATE_VIS regex_traits { public: typedef _CharT char_type; @@ -1285,11 +1291,11 @@ regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const template <class _CharT> class __node; -template <class _BidirectionalIterator> class _LIBCPP_TYPE_VIS_ONLY sub_match; +template <class _BidirectionalIterator> class _LIBCPP_TEMPLATE_VIS sub_match; template <class _BidirectionalIterator, class _Allocator = allocator<sub_match<_BidirectionalIterator> > > -class _LIBCPP_TYPE_VIS_ONLY match_results; +class _LIBCPP_TEMPLATE_VIS match_results; template <class _CharT> struct __state @@ -2403,17 +2409,28 @@ __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const goto __exit; } } - if (!__neg_chars_.empty()) + // set of "__found" chars = + // union(complement(union(__neg_chars_, __neg_mask_)), + // other cases...) + // + // __neg_chars_ and __neg_mask_'d better be handled together, as there + // are no short circuit opportunities. + // + // In addition, when __neg_mask_/__neg_chars_ is empty, they should be + // treated as all ones/all chars. { - for (size_t __i = 0; __i < __neg_chars_.size(); ++__i) - { - if (__ch == __neg_chars_[__i]) - goto __is_neg_char; - } + const bool __in_neg_mask = (__neg_mask_ == 0) || + __traits_.isctype(__ch, __neg_mask_); + const bool __in_neg_chars = + __neg_chars_.empty() || + std::find(__neg_chars_.begin(), __neg_chars_.end(), __ch) != + __neg_chars_.end(); + if (!(__in_neg_mask || __in_neg_chars)) + { __found = true; goto __exit; + } } -__is_neg_char: if (!__ranges_.empty()) { string_type __s2 = __collate_ ? @@ -2445,11 +2462,6 @@ __is_neg_char: __found = true; goto __exit; } - if (__neg_mask_ && !__traits_.isctype(__ch, __neg_mask_)) - { - __found = true; - goto __exit; - } } else __found = __negate_; // force reject @@ -2470,11 +2482,13 @@ __exit: template <class _CharT, class _Traits> class __lookahead; template <class _CharT, class _Traits = regex_traits<_CharT> > -class _LIBCPP_TYPE_VIS_ONLY basic_regex +class _LIBCPP_TEMPLATE_VIS basic_regex { public: // types: typedef _CharT value_type; + typedef _Traits traits_type; + typedef typename _Traits::string_type string_type; typedef regex_constants::syntax_option_type flag_type; typedef typename _Traits::locale_type locale_type; @@ -2515,7 +2529,7 @@ public: __end_(0) {__parse(__p, __p + __traits_.length(__p));} _LIBCPP_INLINE_VISIBILITY - basic_regex(const value_type* __p, size_t __len, flag_type __f) + 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);} @@ -2535,14 +2549,14 @@ public: : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), __end_(0) {__parse(__first, __last);} -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#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());} -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#endif // _LIBCPP_CXX03_LANG // ~basic_regex() = default; @@ -2551,11 +2565,11 @@ public: _LIBCPP_INLINE_VISIBILITY basic_regex& operator=(const value_type* __p) {return assign(__p);} -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_regex& operator=(initializer_list<value_type> __il) {return assign(__il);} -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#endif // _LIBCPP_CXX03_LANG template <class _ST, class _SA> _LIBCPP_INLINE_VISIBILITY basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p) @@ -2565,7 +2579,7 @@ public: _LIBCPP_INLINE_VISIBILITY basic_regex& assign(const basic_regex& __that) {return *this = __that;} -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_regex& assign(basic_regex&& __that) _NOEXCEPT {return *this = _VSTD::move(__that);} @@ -2622,14 +2636,14 @@ public: return assign(basic_regex(__first, __last, __f)); } -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_regex& assign(initializer_list<value_type> __il, flag_type __f = regex_constants::ECMAScript) {return assign(__il.begin(), __il.end(), __f);} -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#endif // _LIBCPP_CXX03_LANG // const operations: _LIBCPP_INLINE_VISIBILITY @@ -2981,10 +2995,12 @@ __lookahead<_CharT, _Traits>::__exec(__state& __s) const { match_results<const _CharT*> __m; __m.__init(1 + __exp_.mark_count(), __s.__current_, __s.__last_); - bool __matched = __exp_.__match_at_start_ecma(__s.__current_, __s.__last_, - __m, - __s.__flags_ | regex_constants::match_continuous, - __s.__at_first_ && __s.__current_ == __s.__first_); + bool __matched = __exp_.__match_at_start_ecma( + __s.__current_, __s.__last_, + __m, + (__s.__flags_ | regex_constants::match_continuous) & + ~regex_constants::__full_match, + __s.__at_first_ && __s.__current_ == __s.__first_); if (__matched != __invert_) { __s.__do_ = __state::__accept_but_not_consume; @@ -3951,7 +3967,6 @@ basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first if (__temp == __last) __throw_regex_error<regex_constants::error_brack>(); // [__first, __temp) contains all text in [= ... =] - typedef typename _Traits::string_type string_type; string_type __collate_name = __traits_.lookup_collatename(__first, __temp); if (__collate_name.empty()) @@ -4049,6 +4064,8 @@ basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first, __first != __last && ( __val = __traits_.value(*__first, 10)) != -1; ++__first) { + if (__c >= std::numeric_limits<int>::max() / 10) + __throw_regex_error<regex_constants::error_badbrace>(); __c *= 10; __c += __val; } @@ -4308,9 +4325,14 @@ basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first, else if ('1' <= *__first && *__first <= '9') { unsigned __v = *__first - '0'; - for (++__first; '0' <= *__first && *__first <= '9'; ++__first) + for (++__first; + __first != __last && '0' <= *__first && *__first <= '9'; ++__first) + { + if (__v >= std::numeric_limits<unsigned>::max() / 10) + __throw_regex_error<regex_constants::error_backref>(); __v = 10 * __v + *__first - '0'; - if (__v > mark_count()) + } + if (__v == 0 || __v > mark_count()) __throw_regex_error<regex_constants::error_backref>(); __push_back_ref(__v); } @@ -4758,7 +4780,7 @@ typedef basic_regex<wchar_t> wregex; // sub_match template <class _BidirectionalIterator> -class _LIBCPP_TYPE_VIS_ONLY sub_match +class _LIBCPP_TEMPLATE_VIS sub_match : public pair<_BidirectionalIterator, _BidirectionalIterator> { public: @@ -5181,7 +5203,7 @@ operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m) } template <class _BidirectionalIterator, class _Allocator> -class _LIBCPP_TYPE_VIS_ONLY match_results +class _LIBCPP_TEMPLATE_VIS match_results { public: typedef _Allocator allocator_type; @@ -5218,11 +5240,11 @@ public: // size: _LIBCPP_INLINE_VISIBILITY - size_type size() const {return __matches_.size();} + size_type size() const _NOEXCEPT {return __matches_.size();} _LIBCPP_INLINE_VISIBILITY - size_type max_size() const {return __matches_.max_size();} - _LIBCPP_INLINE_VISIBILITY - bool empty() const {return size() == 0;} + size_type max_size() const _NOEXCEPT {return __matches_.max_size();} + _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY + bool empty() const _NOEXCEPT {return size() == 0;} // element access: _LIBCPP_INLINE_VISIBILITY @@ -5255,15 +5277,15 @@ public: // format: template <class _OutputIter> _OutputIter - format(_OutputIter __out, const char_type* __fmt_first, + format(_OutputIter __output_iter, const char_type* __fmt_first, const char_type* __fmt_last, regex_constants::match_flag_type __flags = regex_constants::format_default) const; template <class _OutputIter, class _ST, class _SA> _LIBCPP_INLINE_VISIBILITY _OutputIter - format(_OutputIter __out, const basic_string<char_type, _ST, _SA>& __fmt, + format(_OutputIter __output_iter, const basic_string<char_type, _ST, _SA>& __fmt, regex_constants::match_flag_type __flags = regex_constants::format_default) const - {return format(__out, __fmt.data(), __fmt.data() + __fmt.size(), __flags);} + {return format(__output_iter, __fmt.data(), __fmt.data() + __fmt.size(), __flags);} template <class _ST, class _SA> _LIBCPP_INLINE_VISIBILITY basic_string<char_type, _ST, _SA> @@ -5375,7 +5397,7 @@ match_results<_BidirectionalIterator, _Allocator>::__init(unsigned __s, template <class _BidirectionalIterator, class _Allocator> template <class _OutputIter> _OutputIter -match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out, +match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __output_iter, const char_type* __fmt_first, const char_type* __fmt_last, regex_constants::match_flag_type __flags) const { @@ -5384,27 +5406,27 @@ match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out, for (; __fmt_first != __fmt_last; ++__fmt_first) { if (*__fmt_first == '&') - __out = _VSTD::copy(__matches_[0].first, __matches_[0].second, - __out); + __output_iter = _VSTD::copy(__matches_[0].first, __matches_[0].second, + __output_iter); else if (*__fmt_first == '\\' && __fmt_first + 1 != __fmt_last) { ++__fmt_first; if ('0' <= *__fmt_first && *__fmt_first <= '9') { size_t __i = *__fmt_first - '0'; - __out = _VSTD::copy((*this)[__i].first, - (*this)[__i].second, __out); + __output_iter = _VSTD::copy((*this)[__i].first, + (*this)[__i].second, __output_iter); } else { - *__out = *__fmt_first; - ++__out; + *__output_iter = *__fmt_first; + ++__output_iter; } } else { - *__out = *__fmt_first; - ++__out; + *__output_iter = *__fmt_first; + ++__output_iter; } } } @@ -5417,52 +5439,54 @@ match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out, switch (__fmt_first[1]) { case '$': - *__out = *++__fmt_first; - ++__out; + *__output_iter = *++__fmt_first; + ++__output_iter; break; case '&': ++__fmt_first; - __out = _VSTD::copy(__matches_[0].first, __matches_[0].second, - __out); + __output_iter = _VSTD::copy(__matches_[0].first, __matches_[0].second, + __output_iter); break; case '`': ++__fmt_first; - __out = _VSTD::copy(__prefix_.first, __prefix_.second, __out); + __output_iter = _VSTD::copy(__prefix_.first, __prefix_.second, __output_iter); break; case '\'': ++__fmt_first; - __out = _VSTD::copy(__suffix_.first, __suffix_.second, __out); + __output_iter = _VSTD::copy(__suffix_.first, __suffix_.second, __output_iter); break; default: if ('0' <= __fmt_first[1] && __fmt_first[1] <= '9') { ++__fmt_first; - size_t __i = *__fmt_first - '0'; + size_t __idx = *__fmt_first - '0'; if (__fmt_first + 1 != __fmt_last && '0' <= __fmt_first[1] && __fmt_first[1] <= '9') { ++__fmt_first; - __i = 10 * __i + *__fmt_first - '0'; + if (__idx >= std::numeric_limits<size_t>::max() / 10) + __throw_regex_error<regex_constants::error_escape>(); + __idx = 10 * __idx + *__fmt_first - '0'; } - __out = _VSTD::copy((*this)[__i].first, - (*this)[__i].second, __out); + __output_iter = _VSTD::copy((*this)[__idx].first, + (*this)[__idx].second, __output_iter); } else { - *__out = *__fmt_first; - ++__out; + *__output_iter = *__fmt_first; + ++__output_iter; } break; } } else { - *__out = *__fmt_first; - ++__out; + *__output_iter = *__fmt_first; + ++__output_iter; } } } - return __out; + return __output_iter; } template <class _BidirectionalIterator, class _Allocator> @@ -5544,14 +5568,32 @@ basic_regex<_CharT, _Traits>::__match_at_start_ecma( __states.back().__node_ = __st; __states.back().__flags_ = __flags; __states.back().__at_first_ = __at_first; + int __counter = 0; + int __length = __last - __first; do { + ++__counter; + if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && + __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length) + __throw_regex_error<regex_constants::error_complexity>(); __state& __s = __states.back(); if (__s.__node_) __s.__node_->__exec(__s); switch (__s.__do_) { case __state::__end_state: + if ((__flags & regex_constants::match_not_null) && + __s.__current_ == __first) + { + __states.pop_back(); + break; + } + if ((__flags & regex_constants::__full_match) && + __s.__current_ != __last) + { + __states.pop_back(); + break; + } __m.__matches_[0].first = __first; __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ - __first); __m.__matches_[0].matched = true; @@ -5607,14 +5649,32 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs( __states.back().__flags_ = __flags; __states.back().__at_first_ = __at_first; bool __matched = false; + int __counter = 0; + int __length = __last - __first; do { + ++__counter; + if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && + __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length) + __throw_regex_error<regex_constants::error_complexity>(); __state& __s = __states.back(); if (__s.__node_) __s.__node_->__exec(__s); switch (__s.__do_) { case __state::__end_state: + if ((__flags & regex_constants::match_not_null) && + __s.__current_ == __first) + { + __states.pop_back(); + break; + } + if ((__flags & regex_constants::__full_match) && + __s.__current_ != __last) + { + __states.pop_back(); + break; + } if (!__matched || __highest_j < __s.__current_ - __s.__first_) __highest_j = __s.__current_ - __s.__first_; __matched = true; @@ -5692,14 +5752,32 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_subs( __states.back().__at_first_ = __at_first; const _CharT* __current = __first; bool __matched = false; + int __counter = 0; + int __length = __last - __first; do { + ++__counter; + if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && + __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length) + __throw_regex_error<regex_constants::error_complexity>(); __state& __s = __states.back(); if (__s.__node_) __s.__node_->__exec(__s); switch (__s.__do_) { case __state::__end_state: + if ((__flags & regex_constants::match_not_null) && + __s.__current_ == __first) + { + __states.pop_back(); + break; + } + if ((__flags & regex_constants::__full_match) && + __s.__current_ != __last) + { + __states.pop_back(); + break; + } if (!__matched || __highest_j < __s.__current_ - __s.__first_) { __highest_j = __s.__current_ - __s.__first_; @@ -5930,8 +6008,10 @@ regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last, const basic_regex<_CharT, _Traits>& __e, regex_constants::match_flag_type __flags = regex_constants::match_default) { - bool __r = _VSTD::regex_search(__first, __last, __m, __e, - __flags | regex_constants::match_continuous); + bool __r = _VSTD::regex_search( + __first, __last, __m, __e, + __flags | regex_constants::match_continuous | + regex_constants::__full_match); if (__r) { __r = !__m.suffix().matched; @@ -6007,7 +6087,7 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s, template <class _BidirectionalIterator, class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type, class _Traits = regex_traits<_CharT> > -class _LIBCPP_TYPE_VIS_ONLY regex_iterator +class _LIBCPP_TEMPLATE_VIS regex_iterator { public: typedef basic_regex<_CharT, _Traits> regex_type; @@ -6096,7 +6176,7 @@ regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() { __flags_ |= regex_constants::__no_update_pos; _BidirectionalIterator __start = __match_[0].second; - if (__match_.empty()) + if (__match_[0].first == __match_[0].second) { if (__start == __end_) { @@ -6126,7 +6206,7 @@ typedef regex_iterator<wstring::const_iterator> wsregex_iterator; template <class _BidirectionalIterator, class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type, class _Traits = regex_traits<_CharT> > -class _LIBCPP_TYPE_VIS_ONLY regex_token_iterator +class _LIBCPP_TEMPLATE_VIS regex_token_iterator { public: typedef basic_regex<_CharT, _Traits> regex_type; @@ -6142,7 +6222,7 @@ private: _Position __position_; const value_type* __result_; value_type __suffix_; - ptrdiff_t _N_; + ptrdiff_t __n_; vector<int> __subs_; public: @@ -6169,7 +6249,7 @@ public: regex_constants::match_default) = delete; #endif -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#ifndef _LIBCPP_CXX03_LANG regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, const regex_type& __re, initializer_list<int> __submatches, @@ -6183,7 +6263,7 @@ public: regex_constants::match_flag_type __m = regex_constants::match_default) = delete; #endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#endif // _LIBCPP_CXX03_LANG template <size_t _Np> regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, @@ -6225,10 +6305,10 @@ public: private: void __init(_BidirectionalIterator __a, _BidirectionalIterator __b); void __establish_result () { - if (__subs_[_N_] == -1) + if (__subs_[__n_] == -1) __result_ = &__position_->prefix(); else - __result_ = &(*__position_)[__subs_[_N_]]; + __result_ = &(*__position_)[__subs_[__n_]]; } }; @@ -6237,7 +6317,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: regex_token_iterator() : __result_(nullptr), __suffix_(), - _N_(0) + __n_(0) { } @@ -6248,7 +6328,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: { if (__position_ != _Position()) __establish_result (); - else if (__subs_[_N_] == -1) + else if (__subs_[__n_] == -1) { __suffix_.matched = true; __suffix_.first = __a; @@ -6265,7 +6345,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: const regex_type& __re, int __submatch, regex_constants::match_flag_type __m) : __position_(__a, __b, __re, __m), - _N_(0), + __n_(0), __subs_(1, __submatch) { __init(__a, __b); @@ -6277,13 +6357,13 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: const regex_type& __re, const vector<int>& __submatches, regex_constants::match_flag_type __m) : __position_(__a, __b, __re, __m), - _N_(0), + __n_(0), __subs_(__submatches) { __init(__a, __b); } -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#ifndef _LIBCPP_CXX03_LANG template <class _BidirectionalIterator, class _CharT, class _Traits> regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: @@ -6292,13 +6372,13 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: initializer_list<int> __submatches, regex_constants::match_flag_type __m) : __position_(__a, __b, __re, __m), - _N_(0), + __n_(0), __subs_(__submatches) { __init(__a, __b); } -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#endif // _LIBCPP_CXX03_LANG template <class _BidirectionalIterator, class _CharT, class _Traits> template <size_t _Np> @@ -6308,7 +6388,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: const int (&__submatches)[_Np], regex_constants::match_flag_type __m) : __position_(__a, __b, __re, __m), - _N_(0), + __n_(0), __subs_(__submatches, __submatches + _Np) { __init(__a, __b); @@ -6320,7 +6400,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: : __position_(__x.__position_), __result_(__x.__result_), __suffix_(__x.__suffix_), - _N_(__x._N_), + __n_(__x.__n_), __subs_(__x.__subs_) { if (__x.__result_ == &__x.__suffix_) @@ -6342,7 +6422,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: else __result_ = __x.__result_; __suffix_ = __x.__suffix_; - _N_ = __x._N_; + __n_ = __x.__n_; __subs_ = __x.__subs_; if ( __result_ != nullptr && __result_ != &__suffix_ ) @@ -6365,7 +6445,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: return false; if (__result_ == &__suffix_ || __x.__result_ == &__x.__suffix_) return false; - return __position_ == __x.__position_ && _N_ == __x._N_ && + return __position_ == __x.__position_ && __n_ == __x.__n_ && __subs_ == __x.__subs_; } @@ -6376,14 +6456,14 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() _Position __prev = __position_; if (__result_ == &__suffix_) __result_ = nullptr; - else if (_N_ + 1 < __subs_.size()) + else if (static_cast<size_t>(__n_ + 1) < __subs_.size()) { - ++_N_; + ++__n_; __establish_result(); } else { - _N_ = 0; + __n_ = 0; ++__position_; if (__position_ != _Position()) __establish_result(); @@ -6414,7 +6494,7 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; template <class _OutputIterator, class _BidirectionalIterator, class _Traits, class _CharT> _OutputIterator -regex_replace(_OutputIterator __out, +regex_replace(_OutputIterator __output_iter, _BidirectionalIterator __first, _BidirectionalIterator __last, const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt, regex_constants::match_flag_type __flags = regex_constants::match_default) @@ -6425,7 +6505,7 @@ regex_replace(_OutputIterator __out, if (__i == __eof) { if (!(__flags & regex_constants::format_no_copy)) - __out = _VSTD::copy(__first, __last, __out); + __output_iter = _VSTD::copy(__first, __last, __output_iter); } else { @@ -6433,29 +6513,29 @@ regex_replace(_OutputIterator __out, for (size_t __len = char_traits<_CharT>::length(__fmt); __i != __eof; ++__i) { if (!(__flags & regex_constants::format_no_copy)) - __out = _VSTD::copy(__i->prefix().first, __i->prefix().second, __out); - __out = __i->format(__out, __fmt, __fmt + __len, __flags); + __output_iter = _VSTD::copy(__i->prefix().first, __i->prefix().second, __output_iter); + __output_iter = __i->format(__output_iter, __fmt, __fmt + __len, __flags); __lm = __i->suffix(); if (__flags & regex_constants::format_first_only) break; } if (!(__flags & regex_constants::format_no_copy)) - __out = _VSTD::copy(__lm.first, __lm.second, __out); + __output_iter = _VSTD::copy(__lm.first, __lm.second, __output_iter); } - return __out; + return __output_iter; } template <class _OutputIterator, class _BidirectionalIterator, class _Traits, class _CharT, class _ST, class _SA> inline _LIBCPP_INLINE_VISIBILITY _OutputIterator -regex_replace(_OutputIterator __out, +regex_replace(_OutputIterator __output_iter, _BidirectionalIterator __first, _BidirectionalIterator __last, const basic_regex<_CharT, _Traits>& __e, const basic_string<_CharT, _ST, _SA>& __fmt, regex_constants::match_flag_type __flags = regex_constants::match_default) { - return _VSTD::regex_replace(__out, __first, __last, __e, __fmt.c_str(), __flags); + return _VSTD::regex_replace(__output_iter, __first, __last, __e, __fmt.c_str(), __flags); } template <class _Traits, class _CharT, class _ST, class _SA, class _FST, @@ -6518,4 +6598,6 @@ regex_replace(const _CharT* __s, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_REGEX |