diff options
-rw-r--r-- | include/ruby/internal/intern/re.h | 5 | ||||
-rw-r--r-- | internal/re.h | 1 | ||||
-rw-r--r-- | re.c | 17 | ||||
-rw-r--r-- | variable.c | 2 |
4 files changed, 1 insertions, 24 deletions
diff --git a/include/ruby/internal/intern/re.h b/include/ruby/internal/intern/re.h index 31f5593275..4dd58b469b 100644 --- a/include/ruby/internal/intern/re.h +++ b/include/ruby/internal/intern/re.h @@ -87,11 +87,6 @@ void rb_match_busy(VALUE md); * @retval RUBY_Qfalse There is a `n`-th capture and is empty. * @retval RUBY_Qtrue There is a `n`-th capture that has something. * - * @internal - * - * @shyouhei wonders: why there are both rb_reg_match_defined() and - * rb_match_nth_defined, which are largely the same things, but do not share - * their implementations at all? */ VALUE rb_reg_nth_defined(int n, VALUE md); diff --git a/internal/re.h b/internal/re.h index 7b2505b9a8..f85ec09ab3 100644 --- a/internal/re.h +++ b/internal/re.h @@ -22,7 +22,6 @@ VALUE rb_reg_equal(VALUE re1, VALUE re2); void rb_backref_set_string(VALUE string, long pos, long len); void rb_match_unbusy(VALUE); int rb_match_count(VALUE match); -int rb_match_nth_defined(int nth, VALUE match); VALUE rb_reg_new_ary(VALUE ary, int options); #endif /* INTERNAL_RE_H */ @@ -1450,23 +1450,6 @@ rb_match_count(VALUE match) return regs->num_regs; } -int -rb_match_nth_defined(int nth, VALUE match) -{ - struct re_registers *regs; - if (NIL_P(match)) return FALSE; - regs = RMATCH_REGS(match); - if (!regs) return FALSE; - if (nth >= regs->num_regs) { - return FALSE; - } - if (nth < 0) { - nth += regs->num_regs; - if (nth <= 0) return FALSE; - } - return (BEG(nth) != -1); -} - static void match_set_string(VALUE m, VALUE string, long pos, long len) { diff --git a/variable.c b/variable.c index e9735a8c4d..c6c70e1391 100644 --- a/variable.c +++ b/variable.c @@ -902,7 +902,7 @@ rb_f_global_variables(void) int i, nmatch = rb_match_count(backref); buf[0] = '$'; for (i = 1; i <= nmatch; ++i) { - if (!rb_match_nth_defined(i, backref)) continue; + if (!RTEST(rb_reg_nth_defined(i, backref))) continue; if (i < 10) { /* probably reused, make static ID */ buf[1] = (char)(i + '0'); |