diff options
Diffstat (limited to '3rdParty/Boost/src/boost/regex/v4/basic_regex_creator.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/regex/v4/basic_regex_creator.hpp | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/3rdParty/Boost/src/boost/regex/v4/basic_regex_creator.hpp b/3rdParty/Boost/src/boost/regex/v4/basic_regex_creator.hpp index 883ecf1..efa9f7d 100644 --- a/3rdParty/Boost/src/boost/regex/v4/basic_regex_creator.hpp +++ b/3rdParty/Boost/src/boost/regex/v4/basic_regex_creator.hpp @@ -769,14 +769,14 @@ void basic_regex_creator<charT, traits>::fixup_recursions(re_syntax_base* state) case syntax_element_assert_backref: { // just check that the index is valid: - int idVar = static_cast<const re_brace*>(state)->index; - if(idVar < 0) + int idx = static_cast<const re_brace*>(state)->index; + if(idx < 0) { - idVar = -idVar-1; - if(idVar >= 10000) + idx = -idx-1; + if(idx >= 10000) { - idVar = m_pdata->get_id(idVar); - if(idVar <= 0) + idx = m_pdata->get_id(idx); + if(idx <= 0) { // check of sub-expression that doesn't exist: if(0 == this->m_pdata->m_status) // update the error code if not already set @@ -804,12 +804,18 @@ void basic_regex_creator<charT, traits>::fixup_recursions(re_syntax_base* state) { bool ok = false; re_syntax_base* p = base; - int idVar = static_cast<re_jump*>(state)->alt.i; - if(idVar > 10000) - idVar = m_pdata->get_id(idVar); + std::ptrdiff_t idx = static_cast<re_jump*>(state)->alt.i; + if(idx > 10000) + { + // + // There may be more than one capture group with this hash, just do what Perl + // does and recurse to the leftmost: + // + idx = m_pdata->get_id(static_cast<int>(idx)); + } while(p) { - if((p->type == syntax_element_startmark) && (static_cast<re_brace*>(p)->index == idVar)) + if((p->type == syntax_element_startmark) && (static_cast<re_brace*>(p)->index == idx)) { // // We've found the target of the recursion, set the jump target: @@ -833,7 +839,7 @@ void basic_regex_creator<charT, traits>::fixup_recursions(re_syntax_base* state) next_rep_id = static_cast<re_repeat*>(p)->state_id; break; case syntax_element_endmark: - if(static_cast<const re_brace*>(p)->index == idVar) + if(static_cast<const re_brace*>(p)->index == idx) next_rep_id = -1; break; default: @@ -1039,6 +1045,14 @@ int basic_regex_creator<charT, traits>::calculate_backstep(re_syntax_base* state case syntax_element_jump: state = static_cast<re_jump*>(state)->alt.p; continue; + case syntax_element_alt: + { + int r1 = calculate_backstep(state->next.p); + int r2 = calculate_backstep(static_cast<re_alt*>(state)->alt.p); + if((r1 < 0) || (r1 != r2)) + return -1; + return result + r1; + } default: break; } @@ -1543,3 +1557,4 @@ void basic_regex_creator<charT, traits>::probe_leading_repeat(re_syntax_base* st #endif #endif + |