diff --git a/include/boost/regex/v5/perl_matcher_non_recursive.hpp b/include/boost/regex/v5/perl_matcher_non_recursive.hpp index 146eb327..28d6c462 100644 --- a/include/boost/regex/v5/perl_matcher_non_recursive.hpp +++ b/include/boost/regex/v5/perl_matcher_non_recursive.hpp @@ -417,7 +417,8 @@ bool perl_matcher::match_startmark() { // Must be unwinding from a COMMIT/SKIP/PRUNE and the independent // sub failed, need to unwind everything else: - while(unwind(false)); + while (m_backup_state->state_id) + unwind(false); return false; } #if !defined(BOOST_NO_EXCEPTIONS) diff --git a/test/regress/test_perl_ex.cpp b/test/regress/test_perl_ex.cpp index 7f47ecc2..b3b76151 100644 --- a/test/regress/test_perl_ex.cpp +++ b/test/regress/test_perl_ex.cpp @@ -999,6 +999,9 @@ void test_verbs() TEST_REGEX_SEARCH("AA+(*SKIP)(B|Z)|C", perl, "AAAC", match_default, make_array(3, 4, -1, -1, -2, -2)); TEST_REGEX_SEARCH("AA+(*SKIP)(B|Z)|AC", perl, "AAAC", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("AA+(*SKIP)B|C", perl, "AAAC", match_default, make_array(3, 4, -2, -2)); + + // https://github.com/boostorg/regex/issues/152 + TEST_REGEX_SEARCH("\\A((\x1f((?1) )?+)?+(*SKIP) *?(?2)*?)\\z", perl, "\x20\x1f\x1f\x20", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("^(?:aaa(*THEN)\\w{6}|bbb(*THEN)\\w{5}|ccc(*THEN)\\w{4}|\\w{3})", perl, "aaaxxxxxx", match_default, make_array(0, 9, -2, -2)); TEST_REGEX_SEARCH("^(?:aaa(*THEN)\\w{6}|bbb(*THEN)\\w{5}|ccc(*THEN)\\w{4}|\\w{3})", perl, "aaa++++++", match_default, make_array(-2, -2));