forked from boostorg/regex
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:
@ -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
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -125,7 +125,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char
|
||||
#endif
|
||||
expression->re_magic = magic_value;
|
||||
static_cast<c_regex_type*>(expression->guts)->set_expression(ptr, p2, flags);
|
||||
expression->re_nsub = static_cast<c_regex_type*>(expression->guts)->mark_count() - 1;
|
||||
expression->re_nsub = static_cast<c_regex_type*>(expression->guts)->mark_count();
|
||||
result = static_cast<c_regex_type*>(expression->guts)->error_code();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
|
||||
#endif
|
||||
expression->re_magic = wmagic_value;
|
||||
static_cast<wc_regex_type*>(expression->guts)->set_expression(ptr, p2, flags);
|
||||
expression->re_nsub = static_cast<wc_regex_type*>(expression->guts)->mark_count() - 1;
|
||||
expression->re_nsub = static_cast<wc_regex_type*>(expression->guts)->mark_count();
|
||||
result = static_cast<wc_regex_type*>(expression->guts)->error_code();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ void test(boost::basic_regex<charT, traits>& r, const test_regex_search_tag&)
|
||||
}
|
||||
}
|
||||
r.assign(expression, syntax_options | boost::regbase::save_subexpression_location);
|
||||
for(std::size_t i = 1; i < r.mark_count(); ++i)
|
||||
for(std::size_t i = 0; i < r.mark_count(); ++i)
|
||||
{
|
||||
std::pair<const charT*, const charT*> p = r.subexpression(i);
|
||||
if(*p.first != '(')
|
||||
|
Reference in New Issue
Block a user