Hi,

At Tue, 17 Dec 2002 00:39:54 +0900,
Matt Armstrong wrote:
> >>  static VALUE
> >> -rb_reg_match_m(re, str)
> >> -    VALUE re, str;
> >> +rb_reg_match_m(argc, argv, re)
> >
> > Do you like it? :-)
> 
> Yes, though I was thinking that if Regexp#match has the index
> argument, maybe String#match should have it too.

String#match already hasn't it?  Well, you're correct.


Index: string.c =================================================================== RCS file: /cvs/ruby/src/ruby/string.c,v retrieving revision 1.125 diff -u -2 -p -r1.125 string.c --- string.c 10 Dec 2002 06:23:40 -0000 1.125 +++ string.c 16 Dec 2002 17:31:02 -0000 @@ -1000,8 +1000,15 @@ static VALUE get_pat _((VALUE, int)); static VALUE -rb_str_match_m(str, re) - VALUE str, re; +rb_str_match_m(argc, argv, str) + int argc; + VALUE *argv; + VALUE str; { - return rb_funcall(get_pat(re, 0), rb_intern("match"), 1, str); + VALUE re; + if (argc < 1) + rb_raise(rb_eArgError, "wrong number of arguments(%d for 1)", argc); + re = argv[0]; + argv[0] = str; + return rb_funcall2(get_pat(re, 0), rb_intern("match"), argc, argv); } @@ -3173,5 +3180,5 @@ Init_String() rb_define_method(rb_cString, "=~", rb_str_match, 1); rb_define_method(rb_cString, "~", rb_str_match2, 0); - rb_define_method(rb_cString, "match", rb_str_match_m, 1); + rb_define_method(rb_cString, "match", rb_str_match_m, -1); rb_define_method(rb_cString, "succ", rb_str_succ, 0); rb_define_method(rb_cString, "succ!", rb_str_succ_bang, 0);
-- Nobu Nakada