diff --git a/include/boost/regex/v4/basic_regex_creator.hpp b/include/boost/regex/v4/basic_regex_creator.hpp index fec755f8..35de0cef 100644 --- a/include/boost/regex/v4/basic_regex_creator.hpp +++ b/include/boost/regex/v4/basic_regex_creator.hpp @@ -1270,6 +1270,19 @@ void basic_regex_creator::probe_leading_repeat(re_syntax_base* st state = state->next.p; continue; } + if((static_cast(state)->index == -1) + || (static_cast(state)->index == -2)) + { + // skip past the zero width assertion: + state = static_cast(state->next.p)->alt.p->next.p; + continue; + } + if(static_cast(state)->index == -3) + { + // Have to skip the leading jump state: + state = state->next.p->next.p; + continue; + } return; case syntax_element_endmark: case syntax_element_start_line: diff --git a/include/boost/regex/v4/perl_matcher_non_recursive.hpp b/include/boost/regex/v4/perl_matcher_non_recursive.hpp index 3bf34601..e6bf1bba 100644 --- a/include/boost/regex/v4/perl_matcher_non_recursive.hpp +++ b/include/boost/regex/v4/perl_matcher_non_recursive.hpp @@ -1193,6 +1193,9 @@ bool perl_matcher::unwind_char_repeat(bool r) pstate = rep->next.p; }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); } + // remember where we got to if this is a leading repeat: + if((rep->leading) && (count < rep->max)) + restart = position; if(position == last) { // can't repeat any more, remove the pushed state: @@ -1259,6 +1262,9 @@ bool perl_matcher::unwind_short_set_repeat(bool pstate = rep->next.p; }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); } + // remember where we got to if this is a leading repeat: + if((rep->leading) && (count < rep->max)) + restart = position; if(position == last) { // can't repeat any more, remove the pushed state: @@ -1326,6 +1332,9 @@ bool perl_matcher::unwind_long_set_repeat(bool pstate = rep->next.p; }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); } + // remember where we got to if this is a leading repeat: + if((rep->leading) && (count < rep->max)) + restart = position; if(position == last) { // can't repeat any more, remove the pushed state: