[#11952] NORETURN — "Nobuyoshi.Nakada" <nobu.nakada@...>

なかだです。

24 messages 2001/01/10
[#11956] Re: NORETURN — WATANABE Hirofumi <eban@...> 2001/01/10

わたなべです.

[#11957] Re: NORETURN — matz@... (Yukihiro Matsumoto) 2001/01/10

まつもと ゆきひろです

[#11958] Re: NORETURN — WATANABE Hirofumi <eban@...> 2001/01/10

わたなべです.

[#11959] CVS branches (Re: Re: NORETURN) — matz@... (Yukihiro Matsumoto) 2001/01/10

[#12087] string#index, gsub, []= のバグ? — Beyond <beyond@...>

18 messages 2001/01/27
[#12091] Re: string#index, gsub, []= のバグ? — matz@... (Yukihiro Matsumoto) 2001/01/27

まつもと ゆきひろです

[ruby-dev:12020] [BUG] Regexp.last_match(nth)

From: Koji Arai <JCA02266@...>
Date: 2001-01-14 20:58:09 UTC
List: ruby-dev #12020
新井です。

ruby 1.7 の Regexp.last_match がSEGVします

/(.)(.)(.)/ =~ "abc" 
p Regexp.last_match      # => "abc"
p Regexp.last_match(0)   # => "abc"
p Regexp.last_match(1)   # => "a"
p Regexp.last_match(2)   # => "b"
p Regexp.last_match(3)   # => "c"
p Regexp.last_match(4)   # => nil

ruby 1.7.0 (2001-01-10) [i586-linux]
/tmp/hoge.rb:2: [BUG] Segmentation fault
ruby 1.7.0 (2001-01-10) [i586-linux]
Aborted

パッチをこのメールに付けます。

もう一つ、sprintf.cに対するパッチも含んでいます。

# 修正前
p sprintf("%10x", -1)
p sprintf("%10b", -1)

=> "..ffffffff"
   ".........1"

# 修正後
p sprintf("%10x", -1)
p sprintf("%10b", -1)

=> "..ffffffff"
   "..11111111"

ということのようです。今は手元に1.6のソースがないのですが、
きっと1.6 にも反映する必要がありますよね?

--
新井康司 (Koji Arai)


Index: re.c
===================================================================
RCS file: /ruby/ruby/re.c,v
retrieving revision 1.36
diff -u -r1.36 re.c
--- re.c	2001/01/13 10:47:12	1.36
+++ re.c	2001/01/14 20:39:40
@@ -734,7 +734,7 @@
     VALUE nth;
 
     if (rb_scan_args(argc, argv, "01", &nth) == 1) {
-	rb_reg_nth_match(NUM2INT(nth), rb_backref_get());
+	return rb_reg_nth_match(NUM2INT(nth), rb_backref_get());
     }
     return rb_reg_last_match(rb_backref_get());
 }
@@ -1366,7 +1366,7 @@
     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);
Index: sprintf.c
===================================================================
RCS file: /ruby/ruby/sprintf.c,v
retrieving revision 1.13
diff -u -r1.13 sprintf.c
--- sprintf.c	2001/01/10 09:52:13	1.13
+++ sprintf.c	2001/01/14 20:39:41
@@ -566,7 +566,7 @@
 			break;
 		      case 8:
 			c = '7'; break;
-		      case '2':
+		      case 2:
 			c = '1'; break;
 		    }
 		    s = &buf[pos];

In This Thread

Prev Next