Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2008-06-24 12:24:50


Author: eric_niebler
Date: 2008-06-24 12:24:50 EDT (Tue, 24 Jun 2008)
New Revision: 46655
URL: http://svn.boost.org/trac/boost/changeset/46655

Log:
regex iterators hold ref count to regex impl, fixes #1990
Text files modified:
   trunk/boost/xpressive/regex_iterator.hpp | 28 ++++++++++++++--------------
   trunk/boost/xpressive/regex_token_iterator.hpp | 10 +++++-----
   2 files changed, 19 insertions(+), 19 deletions(-)

Modified: trunk/boost/xpressive/regex_iterator.hpp
==============================================================================
--- trunk/boost/xpressive/regex_iterator.hpp (original)
+++ trunk/boost/xpressive/regex_iterator.hpp 2008-06-24 12:24:50 EDT (Tue, 24 Jun 2008)
@@ -40,13 +40,13 @@
       , BidiIter cur
       , BidiIter end
       , BidiIter next_search
- , basic_regex<BidiIter> const *rex
+ , basic_regex<BidiIter> const &rex
       , regex_constants::match_flag_type flags
       , bool not_null = false
     )
- : what_()
- , state_(begin, end, what_, *access::get_regex_impl(*rex), flags)
- , rex_(rex)
+ : rex_(rex)
+ , what_()
+ , state_(begin, end, what_, *access::get_regex_impl(rex_), flags)
       , flags_(flags)
       , not_null_(not_null)
     {
@@ -56,8 +56,8 @@
 
     bool next()
     {
- this->state_.reset(this->what_, *access::get_regex_impl(*this->rex_));
- if(!regex_search_impl(this->state_, *this->rex_, this->not_null_))
+ this->state_.reset(this->what_, *access::get_regex_impl(this->rex_));
+ if(!regex_search_impl(this->state_, this->rex_, this->not_null_))
         {
             return false;
         }
@@ -73,17 +73,17 @@
 
     bool equal_to(regex_iterator_impl<BidiIter> const &that) const
     {
- return this->rex_ == that.rex_
- && this->state_.begin_ == that.state_.begin_
- && this->state_.cur_ == that.state_.cur_
- && this->state_.end_ == that.state_.end_
- && this->flags_ == that.flags_
+ return this->rex_.regex_id() == that.rex_.regex_id()
+ && this->state_.begin_ == that.state_.begin_
+ && this->state_.cur_ == that.state_.cur_
+ && this->state_.end_ == that.state_.end_
+ && this->flags_ == that.flags_
             ;
     }
 
+ basic_regex<BidiIter> rex_;
     match_results<BidiIter> what_;
     match_state<BidiIter> state_;
- basic_regex<BidiIter> const *const rex_;
     regex_constants::match_flag_type const flags_;
     bool not_null_;
 };
@@ -118,7 +118,7 @@
       , basic_regex<BidiIter> const &rex
       , regex_constants::match_flag_type flags = regex_constants::match_default
     )
- : impl_(new impl_type_(begin, begin, end, begin, &rex, flags))
+ : impl_(new impl_type_(begin, begin, end, begin, rex, flags))
     {
         this->next_();
     }
@@ -132,7 +132,7 @@
       , detail::let_<LetExpr> const &args
       , regex_constants::match_flag_type flags = regex_constants::match_default
     )
- : impl_(new impl_type_(begin, begin, end, begin, &rex, flags))
+ : impl_(new impl_type_(begin, begin, end, begin, rex, flags))
     {
         detail::bind_args(args, this->impl_->what_);
         this->next_();

Modified: trunk/boost/xpressive/regex_token_iterator.hpp
==============================================================================
--- trunk/boost/xpressive/regex_token_iterator.hpp (original)
+++ trunk/boost/xpressive/regex_token_iterator.hpp 2008-06-24 12:24:50 EDT (Tue, 24 Jun 2008)
@@ -40,7 +40,7 @@
       , BidiIter cur
       , BidiIter end
       , BidiIter next_search
- , basic_regex<BidiIter> const *rex
+ , basic_regex<BidiIter> const &rex
       , regex_constants::match_flag_type flags = regex_constants::match_default
       , std::vector<int> subs = std::vector<int>(1, 0)
       , int n = -2
@@ -159,7 +159,7 @@
       , BidiIter end
       , basic_regex<BidiIter> const &rex
     )
- : impl_(new impl_type_(begin, begin, end, begin, &rex))
+ : impl_(new impl_type_(begin, begin, end, begin, rex))
     {
         this->next_();
     }
@@ -177,7 +177,7 @@
       , basic_regex<BidiIter> const &rex
       , detail::let_<LetExpr> const &args
     )
- : impl_(new impl_type_(begin, begin, end, begin, &rex))
+ : impl_(new impl_type_(begin, begin, end, begin, rex))
     {
         detail::bind_args(args, this->impl_->iter_.what_);
         this->next_();
@@ -199,7 +199,7 @@
       , Subs const &subs
       , regex_constants::match_flag_type flags = regex_constants::match_default
     )
- : impl_(new impl_type_(begin, begin, end, begin, &rex, flags, detail::to_vector(subs)))
+ : impl_(new impl_type_(begin, begin, end, begin, rex, flags, detail::to_vector(subs)))
     {
         this->next_();
     }
@@ -222,7 +222,7 @@
       , detail::let_<LetExpr> const &args
       , regex_constants::match_flag_type flags = regex_constants::match_default
     )
- : impl_(new impl_type_(begin, begin, end, begin, &rex, flags, detail::to_vector(subs)))
+ : impl_(new impl_type_(begin, begin, end, begin, rex, flags, detail::to_vector(subs)))
     {
         detail::bind_args(args, this->impl_->iter_.what_);
         this->next_();


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk