[#15846] Ruby M17N request — "K.Kosako" <kosako@...>

今書いているライブラリを、あらかじめRuby M17Nに対応させておこうとして、

62 messages 2002/02/04
[#15847] Re: Ruby M17N request — matz@... (Yukihiro Matsumoto) 2002/02/04

まつもと ゆきひろです

[#15854] Re: Ruby M17N request — "K.Kosako" <kosako@...> 2002/02/05

Yukihiro Matsumotoさんの<1012831868.125952.28017.nullmailer@ev.netlab.jp>から

[#16070] Re: Ruby M17N request — "K.Kosako" <kosako@...> 2002/02/25

<20020205045749.0AAA015B@helium.ruby-lang.org>から

[#16072] Re: Ruby M17N request — "Akinori MUSHA" <knu@...> 2002/02/25

At Mon, 25 Feb 2002 19:57:05 +0900,

[#16073] Re: Ruby M17N request — "Akinori MUSHA" <knu@...> 2002/02/25

At Mon, 25 Feb 2002 21:00:46 +0900,

[#16173] Re: Ruby M17N request — "Akinori MUSHA" <knu@...> 2002/03/02

At Mon, 25 Feb 2002 19:57:05 +0900,

[#16196] Oni Guruma imported into our repository — "Akinori MUSHA" <knu@...> 2002/03/04

At Sun, 3 Mar 2002 07:15:40 +0900,

[#16275] Re: Oni Guruma imported into our repository — matz@... (Yukihiro Matsumoto) 2002/03/08

まつもと ゆきひろです

[#16222] Re: Oni Guruma(Re: Ruby M17N request) — nobu.nakada@... 2002/03/05

なかだです。

[#16228] Re: Oni Guruma(Re: Ruby M17N request) — "K.Kosako" <kosako@...> 2002/03/06

nobu.nakada@nifty.ne.jpさんの

[#16237] Re: Oni Guruma(Re: Ruby M17N request) — nobu.nakada@... 2002/03/06

なかだです。

[#16241] Re: Oni Guruma(Re: Ruby M17N request) — "K.Kosako" <kosako@...> 2002/03/07

nobu.nakada@nifty.ne.jpさんの

[#16242] Re: Oni Guruma(Re: Ruby M17N request) — nobu.nakada@... 2002/03/07

なかだです。

[#16442] Re: Oni Guruma(Re: Ruby M17N request) — nobu.nakada@... 2002/03/17

なかだです。

[#15867] [BUG?] include after module definition and extend module — keiju@... (Keiju ISHITSUKA)

けいじゅ@日本ラショナルソフトウェアです.

15 messages 2002/02/08
[#15869] Re: [BUG?] include after module definition and extend module — matz@... (Yukihiro Matsumoto) 2002/02/08

まつもと ゆきひろです

[#15932] Re: [BUG?] include after module definition and extend module — keiju@... (石塚圭樹) 2002/02/18

けいじゅ@日本ラショナルソフトウェアです.

[#15938] Re: [BUG?] include after module definition and extend module — matz@... (Yukihiro Matsumoto) 2002/02/18

まつもと ゆきひろです

[#15914] making net/*.rb grok URI — "Akinori MUSHA" <knu@...>

 net/*.rb モジュール群をぜひとも標準添付となった URI クラスに

30 messages 2002/02/17
[#15915] Re: making net/*.rb grok URI — "Akinori MUSHA" <knu@...> 2002/02/17

At Mon, 18 Feb 2002 04:33:42 +0900,

[#15931] Re: making net/*.rb grok URI — Minero Aoki <aamine@...> 2002/02/18

あおきです。

[#15934] Re: making net/*.rb grok URI — "Akinori MUSHA" <knu@...> 2002/02/18

At Mon, 18 Feb 2002 15:24:22 +0900,

[#15937] Re: making net/*.rb grok URI — Minero Aoki <aamine@...> 2002/02/18

あおきです。

[#15958] Re: making net/*.rb grok URI — TAKAHASHI Masayoshi <maki@...> 2002/02/19

高橋征義です。

[#15978] Re: making net/*.rb grok URI — Tanaka Akira <akr@...17n.org> 2002/02/19

In article <200202190432.NAA18796@mx.inac.co.jp>,

[#16002] Re: making net/*.rb grok URI — TAKAHASHI Masayoshi <maki@...> 2002/02/20

高橋征義です。

[#16013] Re: making net/*.rb grok URI — Tanaka Akira <akr@...17n.org> 2002/02/20

In article <20020221020159R.maki@rubycolor.org>,

[#15988] Re: [rubyist:1097] Re: % 記法 — nobu.nakada@...

なかだです。

21 messages 2002/02/20
[#17594] Re: [rubyist:1097] Re: % 記法 — nobu.nakada@... 2002/06/26

なかだです。

[#16049] defined? autoload constant — Kazuhiro NISHIYAMA <zn@...>

西山和広です。

35 messages 2002/02/24
[#16058] Re: defined? autoload constant — matz@... (Yukihiro Matsumoto) 2002/02/25

まつもと ゆきひろです

[#16298] Re: defined? autoload constant — nobu.nakada@... 2002/03/09

なかだです。

[#16304] Re: defined? autoload constant — matz@... (Yukihiro Matsumoto) 2002/03/09

まつもと ゆきひろです

[#16375] Re: defined? autoload constant — keiju@... (石塚圭樹) 2002/03/14

けいじゅ@日本ラショナルソフトウェアです.

[#16380] Re: defined? autoload constant — nobu.nakada@... 2002/03/14

なかだです。

[#16398] Re: defined? autoload constant — keiju@... (石塚圭樹) 2002/03/14

けいじゅ@日本ラショナルソフトウェアです.

[#16399] Re: defined? autoload constant — nobu.nakada@... 2002/03/14

なかだです。

[#16400] Re: defined? autoload constant — keiju@... (石塚圭樹) 2002/03/14

けいじゅ@日本ラショナルソフトウェアです.

[#16403] Re: defined? autoload constant — matz@... (Yukihiro Matsumoto) 2002/03/14

まつもと ゆきひろです

[#16407] Re: defined? autoload constant — nobu.nakada@... 2002/03/15

なかだです。

[#16409] Re: defined? autoload constant — matz@... (Yukihiro Matsumoto) 2002/03/15

まつもと ゆきひろです

[#16481] Re: defined? autoload constant — keiju@... (石塚圭樹) 2002/03/19

けいじゅ@日本ラショナルソフトウェアです.

[#16482] Re: defined? autoload constant — matz@... (Yukihiro Matsumoto) 2002/03/19

まつもと ゆきひろです

[#16082] Array#select without block — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

14 messages 2002/02/25

[#16102] No trace_func event at if-elsif-else line — "NAKAMURA, Hiroshi" <nakahiro@...>

なひです。

21 messages 2002/02/26
[#16103] Re: No trace_func event at if-elsif-else line — matz@... (Yukihiro Matsumoto) 2002/02/26

まつもと ゆきひろです

[#16109] Re: No trace_func event at if-elsif-else line — "NAKAMURA, Hiroshi" <nakahiro@...> 2002/02/26

なひです。

[#16110] Re: No trace_func event at if-elsif-else line — matz@... (Yukihiro Matsumoto) 2002/02/26

まつもと ゆきひろです

[#16117] Re: No trace_func event at if-elsif-else line — "NAKAMURA, Hiroshi" <nakahiro@...> 2002/02/26

なひです。

[#16127] Re: No trace_func event at if-elsif-else line — matz@... (Yukihiro Matsumoto) 2002/02/26

まつもと ゆきひろです

[#16133] Re: No trace_func event at if-elsif-else line — "NAKAMURA, Hiroshi" <nakahiro@...> 2002/02/27

なひです。

[#16135] Re: No trace_func event at if-elsif-else line — matz@... (Yukihiro Matsumoto) 2002/02/27

まつもと ゆきひろです

[#16256] Rite debug API (was Re: No trace_func event at if-elsif-else line) — "NAKAMURA, Hiroshi" <nakahiro@...> 2002/03/07

なひです。どうせ一年も先の話なのでのんびりと。

[#16258] Re: Rite debug API (was Re: No trace_func event at if-elsif-else line) — matz@... (Yukihiro Matsumoto) 2002/03/07

まつもと ゆきひろです

[#16134] Defining (Python) Source Code Encoding — TAKAHASHI Masayoshi <maki@...>

高橋征義です。ruby-list の「localized document」ともやや関係あり?

13 messages 2002/02/27

[ruby-dev:15835] Re: 文字列→整数変換

From: nobu.nakada@...
Date: 2002-02-01 08:40:38 UTC
List: ruby-dev #15835
なかだです。

At Fri, 1 Feb 2002 10:41:31 +0900,
matz@ruby-lang.org (Yukihiro Matsumoto) wrote:
> |rb_cstr2inum()は、今のところ基数が0ならエラーで例外としてますが、
> |上の二つを追加しようとすると無理があります。badcheckを引数に追
> |加したほうがいいと思うんですが、これのインターフェースって変え
> |ちゃっても大丈夫なもんでしょうか。たぶん使ってる拡張ライブラリ
> |はないとは思うんですが。
> 
> 変えない方が良いんじゃないかなあ。実は以前にも「誰も使ってな
> いだろう」と思って変えちゃったんですが、実際に困ったという話
> を聞いたことがありますので。
> 
> たぶん、元のrb_cstr2inum()をラッパーとして残すのが良いのでは。

ということで、Integer()のほうのパッチです。Float()のほうは別に
します。


Index: bignum.c
===================================================================
RCS file: /cvs/ruby/src/ruby/bignum.c,v
retrieving revision 1.52
diff -u -2 -p -r1.52 bignum.c
--- bignum.c	2002/01/16 02:17:30	1.52
+++ bignum.c	2002/02/01 08:35:12
@@ -187,12 +187,12 @@ rb_int2inum(n)
 
 VALUE
-rb_cstr2inum(str, base)
+rb_cstr_to_inum(str, base, badcheck)
     const char *str;
     int base;
+    int badcheck;
 {
     const char *s = str;
     char *end;
-    int badcheck = (base==0)?1:0;
-    char sign = 1, c;
+    char sign = 1, c, nondigit = 0;
     BDIGIT_DBL num;
     long len, blen = 1;
@@ -201,5 +201,10 @@ rb_cstr2inum(str, base)
     BDIGIT *zds;
 
-    while (*str && ISSPACE(*str)) str++;
+    if (badcheck) {
+	while (ISSPACE(*str)) str++;
+    }
+    else {
+	while (ISSPACE(*str) || *str == '_') str++;
+    }
 
     if (str[0] == '+') {
@@ -214,5 +219,5 @@ rb_cstr2inum(str, base)
 	return INT2FIX(0);
     }
-    if (base == 0) {
+    if (base <= 0) {
 	if (str[0] == '0') {
 	    if (str[1] == 'x' || str[1] == 'X') {
@@ -226,4 +231,7 @@ rb_cstr2inum(str, base)
 	    }
 	}
+	else if (base < -1) {
+	    base = -base;
+	}
 	else {
 	    base = 10;
@@ -291,16 +299,25 @@ rb_cstr2inum(str, base)
 	  case '5': case '6': case '7': 
 	    c = c - '0';
+	    nondigit = 0;
 	    break;
 	  case 'a': case 'b': case 'c':
 	  case 'd': case 'e': case 'f':
-	    if (base != 16) c = base;
-	    else c = c - 'a' + 10;
-	    break;
+	    c -= 'a' - 'A';
 	  case 'A': case 'B': case 'C':
 	  case 'D': case 'E': case 'F':
-	    if (base != 16) c = base;
-	    else c = c - 'A' + 10;
+	    if (base != 16) {
+		nondigit = c;
+		c = base;
+	    }
+	    else {
+		c = c - 'A' + 10;
+		nondigit = 0;
+	    }
 	    break;
 	  case '_':
+	    if (badcheck) {
+		if (nondigit) goto bad;
+		nondigit = c;
+	    }
 	    continue;
 	  default:
@@ -335,7 +352,8 @@ rb_cstr2inum(str, base)
 
 VALUE
-rb_str2inum(str, base)
+rb_str_to_inum(str, base, badcheck)
     VALUE str;
     int base;
+    int badcheck;
 {
     char *s;
@@ -352,8 +370,24 @@ rb_str2inum(str, base)
 	s = p;
     }
-    if (base == 0 && len != strlen(s)) {
+    if (badcheck && len != strlen(s)) {
 	rb_raise(rb_eArgError, "string for Integer contains null byte");
     }
-    return rb_cstr2inum(s, base); 
+    return rb_cstr_to_inum(s, base, badcheck); 
+}
+
+VALUE
+rb_cstr2inum(str, base)
+    const char *str;
+    int base;
+{
+    return rb_cstr_to_inum(str, base, base==0);
+}
+
+VALUE
+rb_str2inum(str, base)
+    VALUE str;
+    int base;
+{
+    return rb_str_to_inum(str, base, base==0);
 }
 
Index: intern.h
===================================================================
RCS file: /cvs/ruby/src/ruby/intern.h,v
retrieving revision 1.77
diff -u -2 -p -u -r1.77 intern.h
--- intern.h	2002/01/11 09:18:50	1.77
+++ intern.h	2002/02/01 05:36:44
@@ -62,4 +62,6 @@ VALUE rb_int2big _((long));
 VALUE rb_uint2inum _((unsigned long));
 VALUE rb_int2inum _((long));
+VALUE rb_cstr_to_inum _((const char*, int, int));
+VALUE rb_str_to_inum _((VALUE, int, int));
 VALUE rb_cstr2inum _((const char*, int));
 VALUE rb_str2inum _((VALUE, int));
Index: object.c
===================================================================
RCS file: /cvs/ruby/src/ruby/object.c,v
retrieving revision 1.71
diff -u -2 -p -u -r1.71 object.c
--- object.c	2002/02/01 06:02:59	1.71
+++ object.c	2002/02/01 08:01:58
@@ -946,5 +946,5 @@ rb_Integer(val)
 
       case T_STRING:
-	return rb_str2inum(val, 0);
+	return rb_str_to_inum(val, 0, Qtrue);
 
       case T_FIXNUM:
Index: parse.y
===================================================================
RCS file: /cvs/ruby/src/ruby/parse.y,v
retrieving revision 1.146
diff -u -2 -p -u -r1.146 parse.y
--- parse.y	2002/01/28 09:33:56	1.146
+++ parse.y	2002/02/01 02:14:35
@@ -3346,5 +3346,5 @@ yylex()
 		    }
 		    else if (nondigit) goto trailing_uc;
-		    yylval.val = rb_cstr2inum(tok(), 16);
+		    yylval.val = rb_cstr_to_inum(tok(), 16, Qfalse);
 		    return tINTEGER;
 		}
@@ -3370,5 +3370,5 @@ yylex()
 		    }
 		    else if (nondigit) goto trailing_uc;
-		    yylval.val = rb_cstr2inum(tok(), 2);
+		    yylval.val = rb_cstr_to_inum(tok(), 2, Qfalse);
 		    return tINTEGER;
 		}
@@ -3389,5 +3389,5 @@ yylex()
 			tokfix();
 			if (nondigit) goto trailing_uc;
-			yylval.val = rb_cstr2inum(tok(), 8);
+			yylval.val = rb_cstr_to_inum(tok(), 8, Qfalse);
 			return tINTEGER;
 		    }
@@ -3483,5 +3483,5 @@ yylex()
 		return tFLOAT;
 	    }
-	    yylval.val = rb_cstr2inum(tok(), 10);
+	    yylval.val = rb_cstr_to_inum(tok(), 10, Qfalse);
 	    return tINTEGER;
 	}
Index: sprintf.c
===================================================================
RCS file: /cvs/ruby/src/ruby/sprintf.c,v
retrieving revision 1.18
diff -u -2 -p -u -r1.18 sprintf.c
--- sprintf.c	2001/10/22 06:48:14	1.18
+++ sprintf.c	2002/02/01 02:14:22
@@ -398,5 +398,5 @@ rb_f_sprintf(argc, argv)
 		    break;
 		  case T_STRING:
-		    val = rb_str2inum(val, 0);
+		    val = rb_str_to_inum(val, 0, Qtrue);
 		    goto bin_retry;
 		  case T_BIGNUM:
Index: string.c
===================================================================
RCS file: /cvs/ruby/src/ruby/string.c,v
retrieving revision 1.96
diff -u -2 -p -u -r1.96 string.c
--- string.c	2002/01/28 08:44:37	1.96
+++ string.c	2002/02/01 07:48:11
@@ -1767,5 +1767,5 @@ rb_str_to_i(argc, argv, str)
 	rb_raise(rb_eArgError, "illegal radix %d", base);
     }
-    return rb_str2inum(str, base);
+    return rb_str_to_inum(str, base, Qfalse);
 }
 
@@ -2964,5 +2964,5 @@ rb_str_hex(str)
     VALUE str;
 {
-    return rb_str2inum(str, 16);
+    return rb_str_to_inum(str, 16, Qfalse);
 }
 
@@ -2971,19 +2971,5 @@ rb_str_oct(str)
     VALUE str;
 {
-    int base = 8;
-
-    if (RSTRING(str)->len > 2 && RSTRING(str)->ptr[0] == '0') {
-	switch (RSTRING(str)->ptr[1]) {
-	  case 'x':
-	  case 'X':
-	    base = 16;
-	    break;
-	  case 'b':
-	  case 'B':
-	    base = 2;
-	    break;
-	}
-    }
-    return rb_str2inum(str, base);
+    return rb_str_to_inum(str, -8, Qfalse);
 }
 
Index: time.c
===================================================================
RCS file: /cvs/ruby/src/ruby/time.c,v
retrieving revision 1.52
diff -u -2 -p -u -r1.52 time.c
--- time.c	2001/12/22 16:58:16	1.52
+++ time.c	2002/02/01 02:12:16
@@ -219,5 +219,5 @@ obj2long(obj)
 {
     if (TYPE(obj) == T_STRING) {
-	obj = rb_str2inum(obj, 10);
+	obj = rb_str_to_inum(obj, 10, Qfalse);
     }
 


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

In This Thread