diff options
author | TSUYUSATO Kitsune <[email protected]> | 2022-12-14 12:57:14 +0900 |
---|---|---|
committer | <[email protected]> | 2022-12-14 12:57:14 +0900 |
commit | fbedadb61f49ba3aaf4f07939b4fc7d0b8f8ac03 () | |
tree | 05f5147da45c55947f220e9e2119b905d97cdab3 | |
parent | fe3cbc61c805a860da3d41253879708ec86b6aa2 (diff) |
Add `Regexp.linear_time?` (#6901)
Notes: Merged-By: makenowjust <[email protected]>
-rw-r--r-- | include/ruby/onigmo.h | 2 | ||||
-rw-r--r-- | re.c | 34 | ||||
-rw-r--r-- | regexec.c | 16 | ||||
-rw-r--r-- | test/ruby/test_regexp.rb | 8 |
4 files changed, 59 insertions, 1 deletions
@@ -854,6 +854,8 @@ OnigPosition onig_search_gpos(OnigRegex, const OnigUChar* str, const OnigUChar* ONIG_EXTERN OnigPosition onig_match(OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* at, OnigRegion* region, OnigOptionType option); ONIG_EXTERN OnigRegion* onig_region_new(void); ONIG_EXTERN void onig_region_init(OnigRegion* region); @@ -4194,6 +4194,39 @@ rb_reg_s_union_m(VALUE self, VALUE args) return rb_reg_s_union(self, args); } /* :nodoc: */ static VALUE rb_reg_init_copy(VALUE copy, VALUE re) @@ -4571,6 +4604,7 @@ Init_Regexp(void) rb_define_singleton_method(rb_cRegexp, "union", rb_reg_s_union_m, -2); rb_define_singleton_method(rb_cRegexp, "last_match", rb_reg_s_last_match, -1); rb_define_singleton_method(rb_cRegexp, "try_convert", rb_reg_s_try_convert, 1); rb_define_method(rb_cRegexp, "initialize", rb_reg_initialize_m, -1); rb_define_method(rb_cRegexp, "initialize_copy", rb_reg_init_copy, 1); @@ -694,7 +694,21 @@ unexpected_bytecode_error: bytecode_error: return ONIGERR_UNDEFINED_BYTECODE; } -#endif /* USE_MATCH_CACHE */ extern void onig_region_clear(OnigRegion* region) @@ -1696,4 +1696,12 @@ class TestRegexp < Test::Unit::TestCase assert_nil(/^a*b?a*$/ =~ "a" * 1000000 + "x") end; end end |