summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNARUSE, Yui <nurse@users.noreply.github.com>2024-02-01 16:13:50 +0900
committerGitHub <noreply@github.com>2024-02-01 07:13:50 +0000
commit7231fc5baa0a44ef6264c795071c5fbec8d1102d (patch)
tree697fb6e74df355f64e950ed55bd631cf02cf6310
parent57d8d6e58a13c9de7bb84c1c76625789f435bca1 (diff)
merge revision(s) 597955a,8b65d15: [Backport #20173] (#9794)
Fix to work match cache with peek next optimization (#9459) --- regexec.c | 3 ++- test/ruby/test_regexp.rb | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) Fix test case for `test_match_cache_with_peek_optimization` (#9466) --- test/ruby/test_regexp.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
-rw-r--r--regexec.c3
-rw-r--r--test/ruby/test_regexp.rb9
-rw-r--r--version.h2
3 files changed, 12 insertions, 2 deletions
diff --git a/regexec.c b/regexec.c
index 8638013618..741fb41278 100644
--- a/regexec.c
+++ b/regexec.c
@@ -3756,14 +3756,15 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
CASE(OP_PUSH_IF_PEEK_NEXT) MOP_IN(OP_PUSH_IF_PEEK_NEXT);
GET_RELADDR_INC(addr, p);
+ CHECK_MATCH_CACHE;
if (*p == *s) {
p++;
- CHECK_MATCH_CACHE;
STACK_PUSH_ALT(p + addr, s, sprev, pkeep);
MOP_OUT;
JUMP;
}
p++;
+ INC_NUM_FAILS;
MOP_OUT;
JUMP;
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index 43357b0c64..91a9f0a96c 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -1945,6 +1945,15 @@ class TestRegexp < Test::Unit::TestCase
end;
end
+ def test_match_cache_with_peek_optimization
+ assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}")
+ timeout = #{ EnvUtil.apply_timeout_scale(10).inspect }
+ begin;
+ Regexp.timeout = timeout
+ assert_nil(/a+z/ =~ "a" * 1000000 + "xz")
+ end;
+ end
+
def test_cache_opcodes_initialize
str = 'test1-test2-test3-test4-test_5'
re = '^([0-9a-zA-Z\-/]*){1,256}$'
diff --git a/version.h b/version.h
index c07bee99d1..6d096a6d5c 100644
--- a/version.h
+++ b/version.h
@@ -11,7 +11,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 6
+#define RUBY_PATCHLEVEL 7
#include "ruby/version.h"
#include "ruby/internal/abi.h"