[#19457] equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org>

ふと気がついたのですが、

39 messages 2003/02/02
[#19460] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/03

まつもと ゆきひろです

[#19473] Re: equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org> 2003/02/04

In article <1044245817.592933.31973.nullmailer@picachu.netlab.jp>,

[#19474] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19475] Re: equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org> 2003/02/04

In article <1044329220.257740.28127.nullmailer@picachu.netlab.jp>,

[#19476] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19477] Re: equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org> 2003/02/04

In article <1044331431.138035.28173.nullmailer@picachu.netlab.jp>,

[#19478] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19479] Re: equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org> 2003/02/04

In article <1044332948.099873.28206.nullmailer@picachu.netlab.jp>,

[#19482] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19486] Re: equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org> 2003/02/04

In article <1044338964.502066.28474.nullmailer@picachu.netlab.jp>,

[#19491] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19493] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19556] compare between String and Exception — Tanaka Akira <akr@...17n.org> 2003/02/12

さらに気が付いたのですが、

[#19514] [Oniguruma] Version 1.7.1 — "K.Kosako" <kosako@...>

ftp.ruby-lang.orgに、onigd20030207.tar.gzを置きました。

19 messages 2003/02/07

[#19548] [PATCH] file.c for (PR#389) and (PR#390) — nobu.nakada@...

なかだです。

20 messages 2003/02/11
[#19572] Re: [PATCH] file.c for (PR#389) and (PR#390) — pegacorn@... 2003/02/14

From: nobu.nakada@nifty.ne.jp

[#19648] Re: SEGV at search_method in eval.c (PR#400) — nobu.nakada@...

なかだです。

13 messages 2003/02/24

[ruby-dev:19528] String#index with offset

From: nobu.nakada@...
Date: 2003-02-07 05:48:46 UTC
List: ruby-dev #19528
なかだです。

"hello".index("l", 3)が0を返します。それとrb_memsearch()もlong
を返すようにしたほうがいいような気がします。引数もlongだし。


Index: intern.h
===================================================================
RCS file: /cvs/ruby/src/ruby/intern.h,v
retrieving revision 1.110
diff -u -2 -p -r1.110 intern.h
--- intern.h	3 Feb 2003 05:34:14 -0000	1.110
+++ intern.h	7 Feb 2003 05:40:52 -0000
@@ -331,5 +331,5 @@ VALUE rb_length_by_each _((VALUE));
 int rb_memcmp _((char*,char*,long));
 int rb_memcicmp _((char*,char*,long));
-int rb_memsearch _((char*,long,char*,long));
+long rb_memsearch _((char*,long,char*,long));
 VALUE rb_reg_nth_defined _((int, VALUE));
 VALUE rb_reg_nth_match _((int, VALUE));
Index: re.c
===================================================================
RCS file: /cvs/ruby/src/ruby/re.c,v
retrieving revision 1.98
diff -u -2 -p -r1.98 re.c
--- re.c	6 Feb 2003 10:06:47 -0000	1.98
+++ re.c	7 Feb 2003 05:40:34 -0000
@@ -97,5 +97,5 @@ rb_memcmp(p1, p2, len)
 }
 
-int
+long
 rb_memsearch(x0, m, y0, n)
     char *x0, *y0;
Index: string.c
===================================================================
RCS file: /cvs/ruby/src/ruby/string.c,v
retrieving revision 1.140
diff -u -2 -p -w -r1.140 string.c
--- string.c	6 Feb 2003 08:25:12 -0000	1.140
+++ string.c	7 Feb 2003 05:41:45 -0000
@@ -840,4 +840,6 @@ rb_str_index(str, sub, offset)
     long offset;
 {
+    long pos;
+
     if (offset < 0) {
 	offset += RSTRING(str)->len;
@@ -846,6 +848,8 @@ rb_str_index(str, sub, offset)
     if (RSTRING(str)->len - offset < RSTRING(sub)->len) return -1;
     if (RSTRING(sub)->len == 0) return offset;
-    return rb_memsearch(RSTRING(sub)->ptr, RSTRING(sub)->len,
+    pos = rb_memsearch(RSTRING(sub)->ptr, RSTRING(sub)->len,
 			RSTRING(str)->ptr+offset, RSTRING(str)->len-offset);
+    if (pos < 0) return pos;
+    return pos + offset;
 }
 


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread

Prev Next