46 lines
2.3 KiB
Diff
46 lines
2.3 KiB
Diff
From 354e02f1413e6a429174e2c1681cc825361c2159 Mon Sep 17 00:00:00 2001
|
|
From: jzmaddock <john@johnmaddock.co.uk>
|
|
Date: Wed, 20 Oct 2021 12:12:57 +0100
|
|
Subject: [PATCH] Correct stack unwinding inside recursions when seeing (*SKIP).
|
|
|
|
Fixes https://github.com/boostorg/regex/issues/152.
|
|
|
|
Signed-off-by: zhangyiru <zhangyiru3@huawei.com>
|
|
Signed-off-by: jzmaddock <john@johnmaddock.co.uk>
|
|
---
|
|
boost/regex/v4/perl_matcher_non_recursive.hpp | 3 ++-
|
|
libs/regex/test/regress/test_perl_ex.cpp | 3 +++
|
|
2 files changed, 5 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/boost/regex/v4/perl_matcher_non_recursive.hpp b/boost/regex/v4/perl_matcher_non_recursive.hpp
|
|
index eb470a78d..e5453e9e7 100644
|
|
--- a/boost/regex/v4/perl_matcher_non_recursive.hpp
|
|
+++ b/boost/regex/v4/perl_matcher_non_recursive.hpp
|
|
@@ -427,7 +427,8 @@ bool perl_matcher<BidiIterator, Allocator, traits>::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/libs/regex/test/regress/test_perl_ex.cpp b/libs/regex/test/regress/test_perl_ex.cpp
|
|
index 6a53256d1..ff74a0742 100644
|
|
--- a/libs/regex/test/regress/test_perl_ex.cpp
|
|
+++ b/libs/regex/test/regress/test_perl_ex.cpp
|
|
@@ -997,6 +997,9 @@ void test_verbs()
|
|
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));
|
|
TEST_REGEX_SEARCH("^(?:aaa(*THEN)\\w{6}|bbb(*THEN)\\w{5}|ccc(*THEN)\\w{4}|\\w{3})", perl, "bbbxxxxx", match_default, make_array(0, 8, -2, -2));
|
|
--
|
|
2.27.0
|
|
|