diff options
author | dim <dim@FreeBSD.org> | 2014-03-05 19:30:36 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-03-05 19:30:36 +0000 |
commit | 22ca1336dcfb663d86a6892dbe1e48eee20bb6db (patch) | |
tree | 72f4bceef54682e8e577b4ddd08c0ad24ea08ff6 /contrib/libc++/include/regex | |
parent | a5552de0b34d11a40bdc1d8e53fa44a923b6b1a8 (diff) | |
download | FreeBSD-src-22ca1336dcfb663d86a6892dbe1e48eee20bb6db.zip FreeBSD-src-22ca1336dcfb663d86a6892dbe1e48eee20bb6db.tar.gz |
MFC r261283:
Import libc++ 3.4 release. This contains a lot of bugfixes, and some
preliminary support for C++1y.
MFC r261604:
HEAD is not buildable for the past day. Commit a 'quick fix' in order to permit
buildworld to complete.
Reviewed by: theraven
MFC r261608:
Apply a cleaner solution for the sign warnings that can occur when
compiling libc++'s <locale> header with -Wsystem-headers on.
This has also been submitted upstream.
Reported by: asomers
MFC r261801:
An ABI incompatibility crept into the libc++ 3.4 import in r261283. It
was caused by upstream libc++ commit r194536, which aimed to make the
headers more standards-compliant, by making std::pair's copy constructor
trivial. Unfortunately, this could cause certain C++ applications using
shared libraries built against the previous version of libc++ to crash.
Fix the ABI incompatibility by making std::pair's copy constructor
non-trivial again.
Please note: Any C++ applications or shared libraries built with libc++
between r261283 and this revision should be recompiled.
Reported by: stefanf
Diffstat (limited to 'contrib/libc++/include/regex')
-rw-r--r-- | contrib/libc++/include/regex | 85 |
1 files changed, 54 insertions, 31 deletions
diff --git a/contrib/libc++/include/regex b/contrib/libc++/include/regex index 312ca11..ffe39cf 100644 --- a/contrib/libc++/include/regex +++ b/contrib/libc++/include/regex @@ -925,7 +925,7 @@ public: }; template <class _CharT> -struct _LIBCPP_TYPE_VIS regex_traits +struct _LIBCPP_TYPE_VIS_ONLY regex_traits { public: typedef _CharT char_type; @@ -970,7 +970,7 @@ public: bool isctype(char_type __c, char_class_type __m) const; _LIBCPP_INLINE_VISIBILITY int value(char_type __ch, int __radix) const - {return __value(__ch, __radix);} + {return __regex_traits_value(__ch, __radix);} locale_type imbue(locale_type __l); _LIBCPP_INLINE_VISIBILITY locale_type getloc()const {return __loc_;} @@ -1001,11 +1001,11 @@ private: __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, wchar_t) const; - static int __value(unsigned char __ch, int __radix); + static int __regex_traits_value(unsigned char __ch, int __radix); _LIBCPP_INLINE_VISIBILITY - int __value(char __ch, int __radix) const - {return __value(static_cast<unsigned char>(__ch), __radix);} - int __value(wchar_t __ch, int __radix) const; + int __regex_traits_value(char __ch, int __radix) const + {return __regex_traits_value(static_cast<unsigned char>(__ch), __radix);} + int __regex_traits_value(wchar_t __ch, int __radix) const; }; template <class _CharT> @@ -1100,7 +1100,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, // lookup_collatename is very FreeBSD-specific -string __get_collation_name(const char* __s); +_LIBCPP_FUNC_VIS string __get_collation_name(const char* __s); template <class _CharT> template <class _ForwardIterator> @@ -1161,7 +1161,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, // lookup_classname -ctype_base::mask __get_classname(const char* __s, bool __icase); +ctype_base::mask _LIBCPP_FUNC_VIS __get_classname(const char* __s, bool __icase); template <class _CharT> template <class _ForwardIterator> @@ -1207,7 +1207,7 @@ regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const template <class _CharT> int -regex_traits<_CharT>::__value(unsigned char __ch, int __radix) +regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix) { if ((__ch & 0xF8u) == 0x30) // '0' <= __ch && __ch <= '7' return __ch - '0'; @@ -1228,18 +1228,18 @@ regex_traits<_CharT>::__value(unsigned char __ch, int __radix) template <class _CharT> inline _LIBCPP_INLINE_VISIBILITY int -regex_traits<_CharT>::__value(wchar_t __ch, int __radix) const +regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const { - return __value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix); + return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix); } template <class _CharT> class __node; -template <class _BidirectionalIterator> class _LIBCPP_TYPE_VIS sub_match; +template <class _BidirectionalIterator> class _LIBCPP_TYPE_VIS_ONLY sub_match; template <class _BidirectionalIterator, class _Allocator = allocator<sub_match<_BidirectionalIterator> > > -class _LIBCPP_TYPE_VIS match_results; +class _LIBCPP_TYPE_VIS_ONLY match_results; template <class _CharT> struct __state @@ -2014,6 +2014,9 @@ public: virtual void __exec(__state&) const; }; +template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<char>::__exec(__state&) const; +template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<wchar_t>::__exec(__state&) const; + // __match_char template <class _CharT> @@ -2415,7 +2418,7 @@ __exit: template <class _CharT, class _Traits> class __lookahead; template <class _CharT, class _Traits = regex_traits<_CharT> > -class _LIBCPP_TYPE_VIS basic_regex +class _LIBCPP_TYPE_VIS_ONLY basic_regex { public: // types: @@ -2769,7 +2772,7 @@ private: void __push_end_marked_subexpression(unsigned); void __push_empty(); void __push_word_boundary(bool); - void __push_lookahead(const basic_regex&, bool); + void __push_lookahead(const basic_regex&, bool, unsigned); template <class _Allocator> bool @@ -2907,6 +2910,7 @@ class __lookahead typedef __owns_one_state<_CharT> base; basic_regex<_CharT, _Traits> __exp_; + unsigned __mexp_; bool __invert_; __lookahead(const __lookahead&); @@ -2915,8 +2919,8 @@ public: typedef _VSTD::__state<_CharT> __state; _LIBCPP_INLINE_VISIBILITY - __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s) - : base(__s), __exp_(__exp), __invert_(__invert) {} + __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s, unsigned __mexp) + : base(__s), __exp_(__exp), __invert_(__invert), __mexp_(__mexp) {} virtual void __exec(__state&) const; }; @@ -2935,6 +2939,9 @@ __lookahead<_CharT, _Traits>::__exec(__state& __s) const { __s.__do_ = __state::__accept_but_not_consume; __s.__node_ = this->first(); + for (unsigned __i = 1; __i < __m.size(); ++__i) { + __s.__sub_matches_[__mexp_ + __i - 1] = __m.__matches_[__i]; + } } else { @@ -3778,7 +3785,7 @@ basic_regex<_CharT, _Traits>::__parse_expression_term(_ForwardIterator __first, } __ml->__add_range(_VSTD::move(__start_range), _VSTD::move(__end_range)); } - else + else if (!__start_range.empty()) { if (__start_range.size() == 1) __ml->__add_char(__start_range[0]); @@ -3786,7 +3793,7 @@ basic_regex<_CharT, _Traits>::__parse_expression_term(_ForwardIterator __first, __ml->__add_digraph(__start_range[0], __start_range[1]); } } - else + else if (!__start_range.empty()) { if (__start_range.size() == 1) __ml->__add_char(__start_range[0]); @@ -4168,7 +4175,9 @@ basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first, basic_regex __exp; __exp.__flags_ = __flags_; __temp = __exp.__parse(++__temp, __last); - __push_lookahead(_VSTD::move(__exp), false); + unsigned __mexp = __exp.__marked_count_; + __push_lookahead(_VSTD::move(__exp), false, __marked_count_); + __marked_count_ += __mexp; #ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __last || *__temp != ')') throw regex_error(regex_constants::error_paren); @@ -4181,7 +4190,9 @@ basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first, basic_regex __exp; __exp.__flags_ = __flags_; __temp = __exp.__parse(++__temp, __last); - __push_lookahead(_VSTD::move(__exp), true); + unsigned __mexp = __exp.__marked_count_; + __push_lookahead(_VSTD::move(__exp), true, __marked_count_); + __marked_count_ += __mexp; #ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __last || *__temp != ')') throw regex_error(regex_constants::error_paren); @@ -4418,7 +4429,8 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first, case 'c': if ((__t = _VSTD::next(__first)) != __last) { - if ('A' <= *__t <= 'Z' || 'a' <= *__t <= 'z') + if (('A' <= *__t && *__t <= 'Z') || + ('a' <= *__t && *__t <= 'z')) { if (__str) *__str = _CharT(*__t % 32); @@ -4426,7 +4438,15 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first, __push_char(_CharT(*__t % 32)); __first = ++__t; } +#ifndef _LIBCPP_NO_EXCEPTIONS + else + throw regex_error(regex_constants::error_escape); +#endif // _LIBCPP_NO_EXCEPTIONS } +#ifndef _LIBCPP_NO_EXCEPTIONS + else + throw regex_error(regex_constants::error_escape); +#endif // _LIBCPP_NO_EXCEPTIONS break; case 'u': ++__first; @@ -4750,10 +4770,11 @@ basic_regex<_CharT, _Traits>::__start_matching_list(bool __negate) template <class _CharT, class _Traits> void basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp, - bool __invert) + bool __invert, + unsigned __mexp) { __end_->first() = new __lookahead<_CharT, _Traits>(__exp, __invert, - __end_->first()); + __end_->first(), __mexp); __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); } @@ -4763,7 +4784,7 @@ typedef basic_regex<wchar_t> wregex; // sub_match template <class _BidirectionalIterator> -class _LIBCPP_TYPE_VIS sub_match +class _LIBCPP_TYPE_VIS_ONLY sub_match : public pair<_BidirectionalIterator, _BidirectionalIterator> { public: @@ -5186,7 +5207,7 @@ operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m) } template <class _BidirectionalIterator, class _Allocator> -class _LIBCPP_TYPE_VIS match_results +class _LIBCPP_TYPE_VIS_ONLY match_results { public: typedef _Allocator allocator_type; @@ -5773,7 +5794,8 @@ basic_regex<_CharT, _Traits>::__search( { __m.__init(1 + mark_count(), __first, __last, __flags & regex_constants::__no_update_pos); - if (__match_at_start(__first, __last, __m, __flags, true)) + if (__match_at_start(__first, __last, __m, __flags, + !(__flags & regex_constants::__no_update_pos))) { __m.__prefix_.second = __m[0].first; __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second; @@ -5810,9 +5832,10 @@ regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last, const basic_regex<_CharT, _Traits>& __e, regex_constants::match_flag_type __flags = regex_constants::match_default) { - basic_string<_CharT> __s(__first, __last); + int __offset = (__flags & regex_constants::match_prev_avail) ? 1 : 0; + basic_string<_CharT> __s(_VSTD::prev(__first, __offset), __last); match_results<const _CharT*> __mc; - bool __r = __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags); + bool __r = __e.__search(__s.data() + __offset, __s.data() + __s.size(), __mc, __flags); __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos); return __r; } @@ -5987,7 +6010,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 regex_iterator +class _LIBCPP_TYPE_VIS_ONLY regex_iterator { public: typedef basic_regex<_CharT, _Traits> regex_type; @@ -6099,7 +6122,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 regex_token_iterator +class _LIBCPP_TYPE_VIS_ONLY regex_token_iterator { public: typedef basic_regex<_CharT, _Traits> regex_type; |