[#3228] Core support for Gems, and namespace — "Luke A. Kanies" <luke@...>

Hi all,

21 messages 2004/07/27
[#3230] Re: Core support for Gems, and namespace — Austin Ziegler <halostatue@...> 2004/07/27

On Tue, 27 Jul 2004 11:39:08 +0900, Luke A. Kanies <luke@madstop.com> wrote:

[#3234] Re: Core support for Gems, and namespace — "Luke A. Kanies" <luke@...> 2004/07/27

On Tue, 27 Jul 2004, Austin Ziegler wrote:

[#3238] Re: Core support for Gems, and namespace — Austin Ziegler <halostatue@...> 2004/07/27

On Wed, 28 Jul 2004 00:14:29 +0900, Luke A. Kanies <luke@madstop.com> wrote:

Re: Trying to understand \G

From: nobu.nokada@...
Date: 2004-07-17 07:41:30 UTC
List: ruby-core #3205
Hi,

At Sat, 17 Jul 2004 15:29:05 +0900,
Yukihiro Matsumoto wrote in [ruby-core:03204]:
> |it'd be nicerif I can write as:
> 
> |  last = 0
> |  while match = words.match(PATT, last)
> |    puts match.begin(0)
> |    puts match.to_s
> |    last = match.end(0)
> |  end
> 
> Done (in HEAD).

Regexp#=~ doesn't accept nil now.

  $ ./i686-linux/miniruby -ve 'p(/./=~nil)'
  ruby 1.9.0 (2004-07-17) [i686-linux]
  -e:1: cannot convert nil into String (TypeError)

  $ ruby -ve 'p(/./=~nil)'
  ruby 1.9.0 (2004-07-16) [i686-linux]
  nil

Too much deleted?

And, what about String#match?


Index: re.c
===================================================================
RCS file: /cvs/ruby/src/ruby/re.c,v
retrieving revision 1.127
diff -u -2 -p -r1.127 re.c
--- re.c	17 Jul 2004 06:28:10 -0000	1.127
+++ re.c	17 Jul 2004 07:36:24 -0000
@@ -1497,4 +1497,8 @@ rb_reg_match_pos(re, str, pos)
     long pos;
 {
+    if (NIL_P(str)) {
+	rb_backref_set(Qnil);
+	return Qnil;
+    }
     StringValue(str);
     if (pos != 0) {
Index: string.c
===================================================================
RCS file: /cvs/ruby/src/ruby/string.c,v
retrieving revision 1.193
diff -u -2 -p -r1.193 string.c
--- string.c	5 Jun 2004 02:30:41 -0000	1.193
+++ string.c	7 Jun 2004 00:52:09 -0000
@@ -1276,8 +1276,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);
 }
 
@@ -4574,5 +4581,5 @@ Init_String()
     rb_define_method(rb_cString, "empty?", rb_str_empty, 0);
     rb_define_method(rb_cString, "=~", rb_str_match, 1);
-    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

In This Thread