summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNARUSE, Yui <naruse@airemix.jp>2024-01-30 10:31:15 +0900
committerNARUSE, Yui <naruse@airemix.jp>2024-01-30 10:31:15 +0900
commit5f3dfa1c273c6fb9eae65ceca633b46f7e30f686 (patch)
treeff2509ad120d8a1ed3045d28b252c20626e40e72
parent818b4ea9b16e3570b431b86da9a24a5743b29617 (diff)
merge revision(s) d8702ddbfbe8cc7fc601a9a4d19842ef9c2b76c1: [Backport #20083]
Fix [Bug #20083]: correct a cache point size for atomic groups (#9367) --- regexec.c | 2 +- test/ruby/test_regexp.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-)
-rw-r--r--regexec.c2
-rw-r--r--test/ruby/test_regexp.rb8
-rw-r--r--version.h2
3 files changed, 10 insertions, 2 deletions
diff --git a/regexec.c b/regexec.c
index 4b02e7f9b5..8638013618 100644
--- a/regexec.c
+++ b/regexec.c
@@ -542,7 +542,7 @@ init_cache_opcodes(const regex_t* reg, OnigCacheOpcode* cache_opcodes, long* num
cache_opcodes->num_cache_points_at_outer_repeat = num_cache_points_at_repeat;\
cache_opcodes->num_cache_points_in_outer_repeat = 0;\
cache_opcodes->lookaround_nesting = lookaround_nesting;\
- cache_point += lookaround_nesting > 0 ? 2 : 1;\
+ cache_point += lookaround_nesting != 0 ? 2 : 1;\
cache_opcodes++;\
} while (0)
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index d4aae16037..b889b1a64e 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -1979,6 +1979,14 @@ class TestRegexp < Test::Unit::TestCase
end
end
+ def test_bug_20083 # [Bug #20083]
+ re = /([\s]*ABC)$/i
+ (1..100).each do |n|
+ text = "#{"0" * n}ABC"
+ assert text.match?(re)
+ end
+ end
+
def test_linear_time_p
assert_send [Regexp, :linear_time?, /a/]
assert_send [Regexp, :linear_time?, 'a']
diff --git a/version.h b/version.h
index 1380a16baa..3cc8349a00 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 1
+#define RUBY_PATCHLEVEL 2
#include "ruby/version.h"
#include "ruby/internal/abi.h"