[#31320] Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...>

-----BEGIN PGP SIGNED MESSAGE-----

124 messages 2007/08/01
[#31321] Re: Import RubyGems to Ruby 1.9 — Nobuyoshi Nakada <nobu@...> 2007/08/01

なかだです。

[#31329] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/08/01

-----BEGIN PGP SIGNED MESSAGE-----

[#31918] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/30

-----BEGIN PGP SIGNED MESSAGE-----

[#31970] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/08

-----BEGIN PGP SIGNED MESSAGE-----

[#32023] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/11

まつもと ゆきひろです

[#32062] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/15

-----BEGIN PGP SIGNED MESSAGE-----

[#32066] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/15

まつもと ゆきひろです

[#32068] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/15

-----BEGIN PGP SIGNED MESSAGE-----

[#32069] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/15

まつもと ゆきひろです

[#32070] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/15

-----BEGIN PGP SIGNED MESSAGE-----

[#32073] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/15

まつもと ゆきひろです

[#32079] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/16

-----BEGIN PGP SIGNED MESSAGE-----

[#32080] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/16

まつもと ゆきひろです

[#32132] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/23

-----BEGIN PGP SIGNED MESSAGE-----

[#32081] Re: Import RubyGems to Ruby 1.9 — Takahiro Kambe <taca@...> 2007/10/16

In message <471447D5.5050902@sarion.co.jp>

[#32087] Re: Import RubyGems to Ruby 1.9 — "Akinori MUSHA" <knu@...> 2007/10/17

 Rubygems は、基本的に他のパッケージシステムから包みやすい作り

[#32104] Re: Import RubyGems to Ruby 1.9 — akira yamada <akira@...> 2007/10/20

Tuesday 16 October 2007 14:09:13 に NAKAMURA, Hiroshi さんは書きました:

[#32109] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/20

-----BEGIN PGP SIGNED MESSAGE-----

[#31332] Re: Import RubyGems to Ruby 1.9 — Tadayoshi Funaba <tadf@...> 2007/08/01

> ちなみに「ruby/1.9.1の標準添付からどのライブラリを外すか?」という議論も

[#31858] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/25

-----BEGIN PGP SIGNED MESSAGE-----

[#31872] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/27

-----BEGIN PGP SIGNED MESSAGE-----

[#31905] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/29

-----BEGIN PGP SIGNED MESSAGE-----

[#31906] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/09/29

まつもと ゆきひろです

[#31910] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/30

-----BEGIN PGP SIGNED MESSAGE-----

[#31920] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/09/30

まつもと ゆきひろです

[#31323] Bignum#to_s の Karatsuba 基数変換による高速化 — "Kenta Murata" <muraken@...>

むらけんです.

16 messages 2007/08/01
[#31326] Re: Bignum#to_s の Karatsuba 基数変換による高速化 — Yukihiro Matsumoto <matz@...> 2007/08/01

まつもと ゆきひろです

[#31327] Re: Bignum#to_s の Karatsuba 基数変換による高速化 — "Kenta Murata" <muraken@...> 2007/08/01

むらけんです.

[#31328] Re: Bignum#to_s の Karatsuba 基数変換による高速化 — Yukihiro Matsumoto <matz@...> 2007/08/01

まつもと ゆきひろです

[#31525] いくつかのバグ報告と提案(5点) — eklerni <eklerni@...>

From:eklerni

13 messages 2007/08/20

[#31539] strtod の精度 — Satoshi Nakagawa <snakagawa@...>

中川といいます。

27 messages 2007/08/20
[#31542] Re: strtod の精度 — Yukihiro Matsumoto <matz@...> 2007/08/20

まつもと ゆきひろです

[ruby-dev:31334] Re: Invalid error message by illegal regexp

From: Nobuyoshi Nakada <nobu@...>
Date: 2007-08-02 06:38:36 UTC
List: ruby-dev #31334
なかだです。

At Thu, 2 Aug 2007 13:45:04 +0900,
KIMURA Koichi wrote in [ruby-dev:31333]:
> ruby -e "/a(?=b)?/.match('a')"
> とか
> ruby -e "/a(?=b?/.match('a')"
> としたときに、
> 
> 0: uninitialized Regexp (TypeError)
> 
> という適切ではないであろうエラーメッセージが出力されます。

すいません。直そうとは思っていたんですが、後回しにしたまま忘れて
ました。

> rb_reg_initialize で失敗した(not 0が返ってきた)ときの対処を変えるか 
> rb_reg_desc内部の判定を調節すれば良いと思いますが、具体的な修正方法
> はお任せします。

元々は、rb_compile_errorを呼ぶときはrb_reg_descには0を渡していた
ので、失敗したら rb_reg_desc(s, len, 0) でもいいと思いますが、オ
プションが表示されていないことに気がつきました。

オプションの変換回りも整理して、こんなところでどうでしょうか。


Index: re.c
===================================================================
--- re.c	(revision 12861)
+++ re.c	(working copy)
@@ -197,4 +197,39 @@ char_to_option(int c)
 }
 
+static char *
+option_to_str(char str[4], int options)
+{
+    char *p = str;
+    if (options & ONIG_OPTION_MULTILINE) *p++ = 'm';
+    if (options & ONIG_OPTION_IGNORECASE) *p++ = 'i';
+    if (options & ONIG_OPTION_EXTEND) *p++ = 'x';
+    *p = 0;
+    return str;
+}
+
+static const char *
+arg_kcode(int options)
+{
+    switch (options & ARG_KCODE_MASK) {
+      case ARG_KCODE_NONE: return "n";
+      case ARG_KCODE_EUC:  return "e";
+      case ARG_KCODE_SJIS: return "s";
+      case ARG_KCODE_UTF8: return "u";
+    }
+    return "";
+}
+
+static const char *
+opt_kcode(int flags)
+{
+    switch (flags) {
+      case KCODE_NONE: return "n";
+      case KCODE_EUC:  return "e";
+      case KCODE_SJIS: return "s";
+      case KCODE_UTF8: return "u";
+    }
+    return "";
+}
+
 extern int
 rb_char_to_option_kcode(int c, int *option, int *kcode)
@@ -417,27 +452,11 @@ rb_reg_desc(const char *s, long len, VAL
     rb_str_buf_cat2(str, "/");
     if (re) {
+	char opts[4];
 	rb_reg_check(re);
-	if (RREGEXP(re)->ptr->options & ONIG_OPTION_MULTILINE)
-	    rb_str_buf_cat2(str, "m");
-	if (RREGEXP(re)->ptr->options & ONIG_OPTION_IGNORECASE)
-	    rb_str_buf_cat2(str, "i");
-	if (RREGEXP(re)->ptr->options & ONIG_OPTION_EXTEND)
-	    rb_str_buf_cat2(str, "x");
+	if (*option_to_str(opts, RREGEXP(re)->ptr->options))
+	    rb_str_buf_cat2(str, opts);
 
 	if (FL_TEST(re, KCODE_FIXED)) {
-	    switch ((RBASIC(re)->flags & KCODE_MASK)) {
-	      case KCODE_NONE:
-		rb_str_buf_cat2(str, "n");
-		break;
-	      case KCODE_EUC:
-		rb_str_buf_cat2(str, "e");
-		break;
-	      case KCODE_SJIS:
-		rb_str_buf_cat2(str, "s");
-		break;
-	      case KCODE_UTF8:
-		rb_str_buf_cat2(str, "u");
-		break;
-	    }
+	    rb_str_buf_cat2(str, opt_kcode(RBASIC(re)->flags & KCODE_MASK));
 	}
     }
@@ -514,4 +533,5 @@ rb_reg_to_s(VALUE re)
     const UChar* ptr;
     VALUE str = rb_str_buf_new2("(?");
+    char optbuf[5];
 
     rb_reg_check(re);
@@ -578,13 +598,10 @@ rb_reg_to_s(VALUE re)
     }
 
-    if (options & ONIG_OPTION_MULTILINE) rb_str_buf_cat2(str, "m");
-    if (options & ONIG_OPTION_IGNORECASE) rb_str_buf_cat2(str, "i");
-    if (options & ONIG_OPTION_EXTEND) rb_str_buf_cat2(str, "x");
+    if (*option_to_str(optbuf, options)) rb_str_buf_cat2(str, optbuf);
 
     if ((options & embeddable) != embeddable) {
-	rb_str_buf_cat2(str, "-");
-	if (!(options & ONIG_OPTION_MULTILINE)) rb_str_buf_cat2(str, "m");
-	if (!(options & ONIG_OPTION_IGNORECASE)) rb_str_buf_cat2(str, "i");
-	if (!(options & ONIG_OPTION_EXTEND)) rb_str_buf_cat2(str, "x");
+	optbuf[0] = '-';
+	option_to_str(optbuf + 1, ~options)
+	rb_str_buf_cat2(str, optbuf);
     }
 
@@ -1528,5 +1545,12 @@ rb_reg_compile(const char *s, long len, 
 
     if (rb_reg_initialize(re, s, len, options, err) != 0) {
-	VALUE desc = rb_reg_desc(s, len, re);
+	char opts[6];
+	VALUE desc = rb_str_buf_new2("/");
+
+	rb_reg_expr_str(desc, s, len);
+	opts[0] = '/';
+	option_to_str(opts + 1, options);
+	strlcat(opts, arg_kcode(options), sizeof(opts));
+	rb_str_buf_cat2(desc, opts);
 	rb_compile_error(file, line, "%s: %s", err, RSTRING_PTR(desc));
     }
@@ -2066,20 +2090,9 @@ rb_reg_s_union(int argc, VALUE *argv)
         args[0] = source;
         args[1] = Qnil;
-        switch (kcode) {
-          case -1:
+        if (kcode == -1) {
             args[2] = Qnil;
-            break;
-          case KCODE_NONE:
-            args[2] = rb_str_new2("n");
-            break;
-          case KCODE_EUC:
-            args[2] = rb_str_new2("e");
-            break;
-          case KCODE_SJIS:
-            args[2] = rb_str_new2("s");
-            break;
-          case KCODE_UTF8:
-            args[2] = rb_str_new2("u");
-            break;
+	}
+	else {
+            args[2] = rb_str_new2(opt_kcode(kcode));
         }
         return rb_class_new_instance(3, args, rb_cRegexp);


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

In This Thread