Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65800 - trunk/boost/regex/v4
From: john_at_[hidden]
Date: 2010-10-07 03:24:03


Author: johnmaddock
Date: 2010-10-07 03:23:58 EDT (Thu, 07 Oct 2010)
New Revision: 65800
URL: http://svn.boost.org/trac/boost/changeset/65800

Log:
Stop accessing/comparing singular iterators.
Fixes #4708.
Text files modified:
   trunk/boost/regex/v4/sub_match.hpp | 19 +++++++++++--------
   1 files changed, 11 insertions(+), 8 deletions(-)

Modified: trunk/boost/regex/v4/sub_match.hpp
==============================================================================
--- trunk/boost/regex/v4/sub_match.hpp (original)
+++ trunk/boost/regex/v4/sub_match.hpp 2010-10-07 03:23:58 EDT (Thu, 07 Oct 2010)
@@ -56,7 +56,7 @@
    template <class T, class A>
    operator std::basic_string<value_type, T, A> ()const
    {
- return std::basic_string<value_type, T, A>(this->first, this->second);
+ return matched ? std::basic_string<value_type, T, A>(this->first, this->second) : std::basic_string<value_type, T, A>();
    }
 #else
    operator std::basic_string<value_type> ()const
@@ -66,19 +66,22 @@
 #endif
    difference_type BOOST_REGEX_CALL length()const
    {
- difference_type n = ::boost::re_detail::distance((BidiIterator)this->first, (BidiIterator)this->second);
+ difference_type n = matched ? ::boost::re_detail::distance((BidiIterator)this->first, (BidiIterator)this->second) : 0;
       return n;
    }
    std::basic_string<value_type> str()const
    {
       std::basic_string<value_type> result;
- std::size_t len = ::boost::re_detail::distance((BidiIterator)this->first, (BidiIterator)this->second);
- result.reserve(len);
- BidiIterator i = this->first;
- while(i != this->second)
+ if(matched)
       {
- result.append(1, *i);
- ++i;
+ std::size_t len = ::boost::re_detail::distance((BidiIterator)this->first, (BidiIterator)this->second);
+ result.reserve(len);
+ BidiIterator i = this->first;
+ while(i != this->second)
+ {
+ result.append(1, *i);
+ ++i;
+ }
       }
       return result;
    }


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