BREAKING CHANGE: change mark_count to do what's documented (and what the std does).

See https://svn.boost.org/trac/boost/ticket/9227.
This commit is contained in:
jzmaddock
2013-12-14 17:43:24 +00:00
parent e5bbcac3da
commit 937cd366c5
6 changed files with 10 additions and 12 deletions

View File

@ -236,9 +236,7 @@ public:
}
std::pair<const_iterator, const_iterator> BOOST_REGEX_CALL subexpression(std::size_t n)const
{
if(n == 0)
boost::throw_exception(std::out_of_range("0 is not a valid subexpression index."));
const std::pair<std::size_t, std::size_t>& pi = this->m_subs.at(n - 1);
const std::pair<std::size_t, std::size_t>& pi = this->m_subs.at(n);
std::pair<const_iterator, const_iterator> p(expression() + pi.first, expression() + pi.second);
return p;
}
@ -266,7 +264,7 @@ public:
}
size_type BOOST_REGEX_CALL mark_count()const
{
return this->m_mark_count;
return this->m_mark_count - 1;
}
const re_detail::re_syntax_base* get_first_state()const
{

View File

@ -200,7 +200,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_imp()
search_base = base;
state_count = 0;
m_match_flags |= regex_constants::match_all;
m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), search_base, last);
m_presult->set_size((m_match_flags & match_nosubs) ? 1 : 1 + re.mark_count(), search_base, last);
m_presult->set_base(base);
m_presult->set_named_subs(this->re.get_named_subs());
if(m_match_flags & match_posix)
@ -262,7 +262,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::find_imp()
// reset our state machine:
search_base = position = base;
pstate = re.get_first_state();
m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), base, last);
m_presult->set_size((m_match_flags & match_nosubs) ? 1 : 1 + re.mark_count(), base, last);
m_presult->set_base(base);
m_presult->set_named_subs(this->re.get_named_subs());
m_match_flags |= regex_constants::match_init;
@ -281,13 +281,13 @@ bool perl_matcher<BidiIterator, Allocator, traits>::find_imp()
++position;
}
// reset $` start:
m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), search_base, last);
m_presult->set_size((m_match_flags & match_nosubs) ? 1 : 1 + re.mark_count(), search_base, last);
//if((base != search_base) && (base == backstop))
// m_match_flags |= match_prev_avail;
}
if(m_match_flags & match_posix)
{
m_result.set_size(re.mark_count(), base, last);
m_result.set_size(1 + re.mark_count(), base, last);
m_result.set_base(base);
}

View File

@ -119,7 +119,7 @@ std::size_t regex_split(OutputIterator out,
// if there is still input left, do a final push as long as max_split
// is not exhausted, and we're not splitting sub-expressions rather
// than whitespace:
if(max_split && (last != s.end()) && (e.mark_count() == 1))
if(max_split && (last != s.end()) && (e.mark_count() == 0))
{
*out = std::basic_string<charT, Traits1, Alloc1>((ci_t)last, (ci_t)s.end());
++out;