From 6a4bec09af7a79ffe1799015e6faae2984269ef8 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 5 May 2008 10:52:44 +0000 Subject: * struct.c (rb_struct_s_def): Struct.new(0) should not SEGV. based on the patch from wanabe in [ruby-dev:34594]. * struct.c (make_struct): call to_str on name object. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- struct.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'struct.c') diff --git a/struct.c b/struct.c index 74d20a426..415032bed 100644 --- a/struct.c +++ b/struct.c @@ -181,7 +181,9 @@ make_struct(VALUE name, VALUE members, VALUE klass) 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 @@ rb_struct_s_def(int argc, VALUE *argv, VALUE klass) ID id; rb_scan_args(argc, argv, "1*", &name, &rest); - for (i=0; i