summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-01-15 07:01:00 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-01-15 07:01:00 +0000
commit971a4d94f074916c6612edd2c3e1090ca71bc531 (patch)
tree6eca3839a0f276f5b36839407473c48e2c53ef67 /re.c
parentac8a2a31c2103abc249544469910ea3ff97f883c (diff)
Mon Jan 15 16:00:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* pack.c (pack_unpack): should check associated pointer packed by pack("P"). restriction added. Sun Jan 14 21:49:28 2001 Koji Arai <JCA02266@nifty.ne.jp> * sprintf.c (rb_f_sprintf): simple typo. binary base should be 2, not '2'. * re.c (rb_reg_s_last_match): should explicitly return nth match. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/re.c b/re.c
index 80bfee6..8a46170 100644
--- a/re.c
+++ b/re.c
@@ -727,19 +727,6 @@ last_match_getter()
}
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()
{
return rb_reg_match_pre(rb_backref_get());
@@ -1028,6 +1015,7 @@ rb_reg_initialize_m(argc, argv, self)
p = rb_str2cstr(src, &len);
rb_reg_initialize(self, p, len, flag);
}
+ return self;
}
static VALUE
@@ -1331,6 +1319,19 @@ match_setter(val)
rb_backref_set(val);
}
+static VALUE
+rb_reg_s_last_match(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ VALUE nth;
+
+ if (rb_scan_args(argc, argv, "01", &nth) == 1) {
+ return rb_reg_nth_match(NUM2INT(nth), rb_backref_get());
+ }
+ return match_getter();
+}
+
void
Init_Regexp()
{
@@ -1366,7 +1367,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", rb_reg_s_last_match, 0);
+ rb_define_singleton_method(rb_cRegexp, "last_match", rb_reg_s_last_match, -1);
rb_define_method(rb_cRegexp, "initialize", rb_reg_initialize_m, -1);
rb_define_method(rb_cRegexp, "clone", rb_reg_clone, 0);