[#44066] Ruby 1.8.6-p111 / 1.8.5-p114 released (Security Fix) — Urabe Shyouhei <shyouhei@...>

Hi all.

18 messages 2007/10/04
[#44067] Re: Ruby 1.8.6-p111 / 1.8.5-p114 released (Security Fix) — Takahiro Kambe <taca@...> 2007/10/04

こんにちは。

[#44068] Re: Ruby 1.8.6-p111 / 1.8.5-p114 released (Security Fix) — Shugo Maeda <shugo@...> 2007/10/04

前田です。

[#44090] Windowsアプリにrubyを組み込んだときのエラーメッセージ — "湊大典" <minato.daisuke@...>

こんにちは。

19 messages 2007/10/07
[#44091] Re: Windowsアプリにrubyを組み込んだときのエラーメッセージ — Nobuyoshi Nakada <nobu@...> 2007/10/09

なかだです。

[#44097] Re: Windowsアプリにrubyを組み込んだときのエラーメッセージ — "湊大典" <minato.daisuke@...> 2007/10/10

こんばんは、中田さん。

[#44098] Re: Windowsアプリにrubyを組み込んだときのエラーメッセージ — "U.Nakamura" <usa@...> 2007/10/10

こんにちは、なかむら(う)です。

[#44103] Re: Windowsアプリにrubyを組み込んだときのエラーメッセージ — "湊大典" <minato.daisuke@...> 2007/10/11

こんにちは、中村さん。

[#44104] Re: Windowsアプリにrubyを組み込んだときのエラーメッセージ — Nobuyoshi Nakada <nobu@...> 2007/10/11

なかだです。

[#44105] Re: Windowsアプリにrubyを組み込んだときのエラーメッセージ — "湊大典" <minato.daisuke@...> 2007/10/12

そうなんですか。

[#44106] Re: Windowsアプリにrubyを組み込んだときのエラーメッセージ — "きむらこういち" <hogemuta@...> 2007/10/12

木村です。

[#44108] Re: Windowsアプリにrubyを組み込んだときのエラーメッセージ — pegacorn <subscriber.jp@...> 2007/10/12

From: "きむらこういち" <hogemuta@gmail.com>

[#44109] Re: Windowsアプリにrubyを組み込んだときのエラーメッセージ — "Nobuyoshi Nakada" <nobu@...> 2007/10/13

なかだです。

[#44125] ruby-tk with tcltk8.5b1 — Ryutaro Amano <wn9r-amn@...>

天野竜太郎と申します。

14 messages 2007/10/19

[#44147] 2個づつの組を作る方法のすべて — "142QN4969@..." <ohrs@...>

小原と申します。御世話になっています。

15 messages 2007/10/27

[ruby-list:44084] Re: Regexp.union([pattern, ...]) に騙されました

From: Tanaka Akira <akr@...>
Date: 2007-10-05 12:22:07 UTC
List: ruby-list #44084
In article <20071005.195204.74730688.dezawa@aliadne.net>,
  しん <dezawa@aliadne.net> writes:

> そのなかで Regexp.union なるものに興味を持ったのですが、当時の仕事では
> 使わずじまい。今回それが役に立ちそうな仕事があって使ってみたのですが
> 騙されました。
> Regexp.union([pattern, ...]) とあったので 引き数に pattern とすべき
> String の Array を入れたのですが怒られました。
> [  ] はArrayではなく 省略可能引き数 だったのだ、、、

それも受け付けるようにしましょうか。

Index: re.c
===================================================================
--- re.c	(リビジョン 13636)
+++ re.c	(作業コピー)
@@ -2042,12 +2042,13 @@
 
 /*
  *  call-seq:
- *     Regexp.union([pattern]*)   => new_str
+ *     Regexp.union([pattern]*)         => new_regexp
+ *     Regexp.union(array_of_patterns)  => new_regexp
  *
  *  Return a <code>Regexp</code> object that is the union of the given
  *  <em>pattern</em>s, i.e., will match any of its parts. The <em>pattern</em>s
  *  can be Regexp objects, in which case their options will be preserved, or
- *  Strings. If no arguments are given, returns <code>/(?!)/</code>.
+ *  Strings. If no patterns are given, returns <code>/(?!)/</code>.
  *
  *     Regexp.union                         #=> /(?!)/
  *     Regexp.union("penzance")             #=> /penzance/
@@ -2055,8 +2056,9 @@
  *     Regexp.union(/dogs/, /cats/i)        #=> /(?-mix:dogs)|(?i-mx:cats)/
  */
 static VALUE
-rb_reg_s_union(int argc, VALUE *argv)
+rb_reg_s_union(VALUE self, VALUE args0)
 {
+    long argc = RARRAY_LEN(args0);
     if (argc == 0) {
         VALUE args[1];
         args[0] = rb_str_new2("(?!)");
@@ -2064,12 +2066,12 @@
     }
     else if (argc == 1) {
         VALUE v;
-        v = rb_check_regexp_type(argv[0]);
+        v = rb_check_regexp_type(rb_ary_entry(args0, 0));
         if (!NIL_P(v))
             return v;
         else {
             VALUE args[1];
-            args[0] = rb_reg_s_quote(argc, argv);
+            args[0] = rb_reg_s_quote(RARRAY_LEN(args0), RARRAY_PTR(args0));
             return rb_class_new_instance(1, args, rb_cRegexp);
         }
     }
@@ -2082,7 +2084,7 @@
             volatile VALUE v;
             if (0 < i)
                 rb_str_buf_cat2(source, "|");
-            v = rb_check_regexp_type(argv[i]);
+            v = rb_check_regexp_type(rb_ary_entry(args0, i));
             if (!NIL_P(v)) {
                 if (FL_TEST(v, KCODE_FIXED)) {
                     if (kcode == -1) {
@@ -2100,7 +2102,7 @@
                 v = rb_reg_to_s(v);
             }
             else {
-                args[0] = argv[i];
+                args[0] = rb_ary_entry(args0, i);
                 v = rb_reg_s_quote(1, args);
             }
             rb_str_buf_append(source, v);
@@ -2117,6 +2119,17 @@
     }
 }
 
+static VALUE
+rb_reg_s_union_m(VALUE self, VALUE args)
+{
+    VALUE v;
+    if (RARRAY_LEN(args) == 1 &&
+        !NIL_P(v = rb_check_array_type(rb_ary_entry(args, 0)))) {
+        return rb_reg_s_union(self, v);
+    }
+    return rb_reg_s_union(self, args);
+}
+
 /* :nodoc: */
 static VALUE
 rb_reg_init_copy(VALUE copy, VALUE re)
@@ -2416,7 +2429,7 @@
     rb_define_singleton_method(rb_cRegexp, "compile", rb_class_new_instance, -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, "union", rb_reg_s_union, -1);
+    rb_define_singleton_method(rb_cRegexp, "union", rb_reg_s_union_m, -2);
     rb_define_singleton_method(rb_cRegexp, "last_match", rb_reg_s_last_match, -1);
     rb_define_singleton_method(rb_cRegexp, "try_convert", rb_reg_s_try_convert, 1);
 
-- 
[田中 哲][たなか あきら][Tanaka Akira]

In This Thread