diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2014-01-09 18:25:57 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2014-01-09 18:25:57 +0000 |
commit | 79b0fee3c682dcc198e58a8ac7b5e1af5c03467f (patch) | |
tree | aa114b714036dfaa4e339fa39d3b3291dc72248f /libcxx/include/regex | |
parent | 0ba86b73aa51c6bd7d2e3e48262ab10e7c348ded (diff) | |
download | bcm5719-llvm-79b0fee3c682dcc198e58a8ac7b5e1af5c03467f.tar.gz bcm5719-llvm-79b0fee3c682dcc198e58a8ac7b5e1af5c03467f.zip |
Fix PR18404 - 'Bug in regex_token_iterator::operator++(int) implementation'. Enhance the tests for regex_token_iterator and regex_iterator.
llvm-svn: 198878
Diffstat (limited to 'libcxx/include/regex')
-rw-r--r-- | libcxx/include/regex | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/libcxx/include/regex b/libcxx/include/regex index ffe39cf1cff..f8569f950bc 100644 --- a/libcxx/include/regex +++ b/libcxx/include/regex @@ -6188,6 +6188,12 @@ public: private: void __init(_BidirectionalIterator __a, _BidirectionalIterator __b); + void __establish_result () { + if (__subs_[_N_] == -1) + __result_ = &__position_->prefix(); + else + __result_ = &(*__position_)[__subs_[_N_]]; + } }; template <class _BidirectionalIterator, class _CharT, class _Traits> @@ -6205,12 +6211,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: __init(_BidirectionalIterator __a, _BidirectionalIterator __b) { if (__position_ != _Position()) - { - if (__subs_[_N_] == -1) - __result_ = &__position_->prefix(); - else - __result_ = &(*__position_)[__subs_[_N_]]; - } + __establish_result (); else if (__subs_[_N_] == -1) { __suffix_.matched = true; @@ -6288,6 +6289,8 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: { if (__x.__result_ == &__x.__suffix_) __result_ == &__suffix_; + else if ( __result_ != nullptr ) + __establish_result (); } template <class _BidirectionalIterator, class _CharT, class _Traits> @@ -6299,12 +6302,15 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: { __position_ = __x.__position_; if (__x.__result_ == &__x.__suffix_) - __result_ == &__suffix_; + __result_ = &__suffix_; else __result_ = __x.__result_; __suffix_ = __x.__suffix_; _N_ = __x._N_; __subs_ = __x.__subs_; + + if ( __result_ != nullptr && __result_ != &__suffix_ ) + __establish_result(); } return *this; } @@ -6337,22 +6343,14 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() else if (_N_ + 1 < __subs_.size()) { ++_N_; - if (__subs_[_N_] == -1) - __result_ = &__position_->prefix(); - else - __result_ = &(*__position_)[__subs_[_N_]]; + __establish_result(); } else { _N_ = 0; ++__position_; if (__position_ != _Position()) - { - if (__subs_[_N_] == -1) - __result_ = &__position_->prefix(); - else - __result_ = &(*__position_)[__subs_[_N_]]; - } + __establish_result(); else { if (_VSTD::find(__subs_.begin(), __subs_.end(), -1) != __subs_.end() |