[前][次][番号順一覧][スレッド一覧]

ruby-changes:4801

From: ko1@a...
Date: Mon, 5 May 2008 19:53:07 +0900 (JST)
Subject: [ruby-changes:4801] matz - Ruby:r16295 (trunk): * struct.c (rb_struct_s_def): Struct.new(0) should not SEGV.

matz	2008-05-05 19:52:44 +0900 (Mon, 05 May 2008)

  New Revision: 16295

  Modified files:
    trunk/ChangeLog
    trunk/struct.c

  Log:
    * struct.c (rb_struct_s_def): Struct.new(0) should not SEGV.
      based on the patch from wanabe <s.wanabe at gmail.com> in
      [ruby-dev:34594].
    
    * struct.c (make_struct): call to_str on name object.

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16295&r2=16294&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/struct.c?r1=16295&r2=16294&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 16294)
+++ ChangeLog	(revision 16295)
@@ -1,3 +1,11 @@
+Mon May  5 19:49:59 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* struct.c (rb_struct_s_def): Struct.new(0) should not SEGV.
+	  based on the patch from wanabe <s.wanabe at gmail.com> in
+	  [ruby-dev:34594].
+
+	* struct.c (make_struct): call to_str on name object.
+
 Mon May  5 17:17:40 2008  Tanaka Akira  <akr@f...>
 
 	* eval.c (ruby_cleanup): wrap ruby_finalize_0 by SAVE_ROOT_JMPBUF to
Index: struct.c
===================================================================
--- struct.c	(revision 16294)
+++ struct.c	(revision 16295)
@@ -181,7 +181,9 @@
 	rb_class_inherited(klass, nstr);
     }
     else {
-	id = SYM2ID(rb_str_intern(name));
+	/* old style: should we warn? */
+	name = rb_str_to_str(name);
+	id = rb_to_id(name);
 	if (!rb_is_const_id(id)) {
 	    rb_name_error(id, "identifier %s needs to be constant", StringValuePtr(name));
 	}
@@ -322,14 +324,14 @@
     ID id;
 
     rb_scan_args(argc, argv, "1*", &name, &rest);
+    if (!NIL_P(name) && SYMBOL_P(name)) {
+	rb_ary_unshift(rest, name);
+	name = Qnil;
+    }
     for (i=0; i<RARRAY_LEN(rest); i++) {
 	id = rb_to_id(RARRAY_PTR(rest)[i]);
 	RARRAY_PTR(rest)[i] = ID2SYM(id);
     }
-    if (!NIL_P(name) && SYMBOL_P(name)) {
-	rb_ary_unshift(rest, name);
-	name = Qnil;
-    }
     st = make_struct(name, rest, klass);
     if (rb_block_given_p()) {
 	rb_mod_module_eval(0, 0, st);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]