diff options
author | Yusuke Endoh <[email protected]> | 2022-03-24 16:59:11 +0900 |
---|---|---|
committer | Yusuke Endoh <[email protected]> | 2022-03-30 16:50:46 +0900 |
commit | ffc3b37f969a779f93b8f8a5b3591b4ef7de1538 () | |
tree | 25b2d942e8eb2c4a73043773edfcfd6c0d709155 | |
parent | 23530d68cb04aed9c2f59a050523b0193ee2d0c1 (diff) |
re.c: Add Regexp.timeout= and Regexp.timeout
[Feature #17837]
Notes: Merged: https://.com/ruby/ruby/pull/5703
-rw-r--r-- | include/ruby/onigmo.h | 7 | ||||
-rw-r--r-- | re.c | 88 | ||||
-rw-r--r-- | regcomp.c | 3 | ||||
-rw-r--r-- | regexec.c | 2 | ||||
-rw-r--r-- | regint.h | 8 | ||||
-rw-r--r-- | test/ruby/test_regexp.rb | 17 |
6 files changed, 125 insertions, 0 deletions
@@ -793,6 +793,13 @@ typedef struct re_pattern_buffer { OnigDistance dmin; /* min-distance of exact or map */ OnigDistance dmax; /* max-distance of exact or map */ /* regex_t link chain */ struct re_pattern_buffer* chain; /* escape compile-conflict */ } OnigRegexType; @@ -14,12 +14,14 @@ #include <ctype.h> #include "encindex.h" #include "internal.h" #include "internal/hash.h" #include "internal/imemo.h" #include "internal/re.h" #include "internal/string.h" #include "internal/variable.h" #include "regint.h" #include "ruby/encoding.h" #include "ruby/re.h" @@ -1593,6 +1595,9 @@ rb_reg_prepare_re0(VALUE re, VALUE str, onig_errmsg_buffer err) rb_raise(rb_eArgError, "regexp preprocess failed: %s", err); } const char *ptr; long len; RSTRING_GETMEM(unescaped, ptr, len); @@ -1604,6 +1609,8 @@ rb_reg_prepare_re0(VALUE re, VALUE str, onig_errmsg_buffer err) rb_reg_raise(pattern, RREGEXP_SRC_LEN(re), err, re); } RB_GC_GUARD(unescaped); return reg; } @@ -4091,6 +4098,84 @@ re_warn(const char *s) rb_warn("%s", s); } /* * Document-class: RegexpError * @@ -4170,6 +4255,9 @@ Init_Regexp(void) rb_define_method(rb_cRegexp, "names", rb_reg_names, 0); rb_define_method(rb_cRegexp, "named_captures", rb_reg_named_captures, 0); /* see Regexp.options and Regexp.new */ rb_define_const(rb_cRegexp, "IGNORECASE", INT2FIX(ONIG_OPTION_IGNORECASE)); /* see Regexp.options and Regexp.new */ @@ -5973,6 +5973,9 @@ onig_reg_init(regex_t* reg, OnigOptionType option, (reg)->name_table = (void* )NULL; (reg)->case_fold_flag = case_fold_flag; return 0; } @@ -422,6 +422,7 @@ onig_region_copy(OnigRegion* to, const OnigRegion* from) (msa).gpos = (arg_gpos);\ (msa).best_len = ONIG_MISMATCH;\ (msa).counter = 0;\ } while(0) #else # define MATCH_ARG_INIT(msa, arg_option, arg_region, arg_start, arg_gpos) do {\ @@ -431,6 +432,7 @@ onig_region_copy(OnigRegion* to, const OnigRegion* from) (msa).start = (arg_start);\ (msa).gpos = (arg_gpos);\ (msa).counter = 0;\ } while(0) #endif @@ -152,6 +152,7 @@ msa->counter++; \ if (msa->counter >= 128) { \ msa->counter = 0; \ rb_thread_check_ints(); \ } \ } while(0) @@ -877,6 +878,12 @@ typedef struct { int state_check_buff_size; #endif int counter; } OnigMatchArg; @@ -942,6 +949,7 @@ extern int onig_st_insert_strend(hash_table_type* table, const UChar* str_key, c #ifdef RUBY extern size_t onig_memsize(const regex_t *reg); extern size_t onig_region_memsize(const struct re_registers *regs); #endif RUBY_SYMBOL_EXPORT_END @@ -1457,4 +1457,21 @@ class TestRegexp < Test::Unit::TestCase } assert_empty(errs, msg) end end |