From 87beea44969367180d255f56c4001348cf41d210 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 9 Jan 2001 07:26:21 +0000 Subject: * enum.c (enum_inject): new method. * gc.c (rb_gc_call_finalizer_at_exit): clear klass member of terminating object. * eval.c (rb_call): raise exception for terminated object. * bignum.c (bigdivrem): t2 might be too big for signed long; do not use rb_int2big(), but rb_uint2big(). * error.c (rb_load_fail): new func to report LoadError. * ruby.c (load_file): use rb_load_fail. * eval.c (ruby_finalize): should enclosed by PUSH_TAG/POP_TAG. * gc.c (rb_gc_mark): link 2 of NODE_IFUNC should not be explicitly marked. it may contain non object pointer. * re.c (reg_s_last_match): Regexp::last_match(nth) returns nth substring of the match (alternative for $& and $). * eval.c (rb_mod_define_method): wrong comparison for blocks. * gc.c (id2ref): should handle Symbol too. * gc.c (id2ref): should print original ptr value * eval.c (rb_iterate): NODE_CFUNC does not protect its data (nd_tval), so create new node NODE_IFUNC for iteration C function. * eval.c (rb_yield_0): use NODE_IFUNC. * gc.c (rb_gc_mark): support NODE_IFUNC. * gc.c (mem_error): prohibit recursive mem_error(). (ruby-bugs-ja:PR#36) * eval.c (rb_thread_fd_writable): should not switch context if rb_thread_critical is set. * eval.c (rb_thread_wait_fd): ditto. * eval.c (rb_thread_wait_for): ditto. * eval.c (rb_thread_select): ditto. * eval.c (rb_thread_join): join during critical section causes deadlock. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- re.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 're.c') diff --git a/re.c b/re.c index bb9898fdb4..9d1a282dee 100644 --- a/re.c +++ b/re.c @@ -726,6 +726,19 @@ last_match_getter() return rb_reg_last_match(rb_backref_get()); } +static VALUE +rb_reg_s_last_match(argc, argv) + int argc; + VALUE *argv; +{ + VALUE nth; + + if (rb_scan_args(argc, argv, "01", &nth) == 1) { + rb_reg_nth_match(NUM2INT(nth), rb_backref_get()); + } + return rb_reg_last_match(rb_backref_get()); +} + static VALUE prematch_getter() { @@ -1347,7 +1360,7 @@ Init_Regexp() rb_define_singleton_method(rb_cRegexp, "compile", rb_reg_s_new, -1); rb_define_singleton_method(rb_cRegexp, "quote", rb_reg_s_quote, -1); rb_define_singleton_method(rb_cRegexp, "escape", rb_reg_s_quote, -1); - rb_define_singleton_method(rb_cRegexp, "last_match", match_getter, 0); + rb_define_singleton_method(rb_cRegexp, "last_match", rb_reg_s_last_match, 0); rb_define_method(rb_cRegexp, "initialize", rb_reg_initialize_m, -1); rb_define_method(rb_cRegexp, "clone", rb_reg_clone, 0); -- cgit v1.2.3