summaryrefslogtreecommitdiff
path: root/struct.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-10 07:05:19 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-10 07:05:19 +0000
commit7c097dc8914e035dc4e1fb6913064e59fcb3d08c (patch)
tree9832727d5254de4909d2e1a2a5e497bb06c5d8e9 /struct.c
parent86e988a55596ab35e48a39fff4638afdb619fbc7 (diff)
* struct.c (rb_struct_s_def): Struct::new executes block with
generated struct class. [ruby-talk:02606] * io.c (rb_io_ungetc): raise IOError instead of calling rb_sys_fail(). [ruby-talk:23181] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/struct.c b/struct.c
index fd149e3c75..1a8c44ad02 100644
--- a/struct.c
+++ b/struct.c
@@ -285,12 +285,19 @@ rb_struct_s_def(argc, argv, klass)
id = rb_to_id(RARRAY(rest)->ptr[i]);
RARRAY(rest)->ptr[i] = ID2SYM(id);
}
- if (!NIL_P(name) && TYPE(name) != T_STRING) {
- id = rb_to_id(name);
- rb_ary_unshift(rest, ID2SYM(id));
- name = Qnil;
+ if (!NIL_P(name)) {
+ VALUE tmp = rb_check_string_type(name);
+
+ if (NIL_P(tmp)) {
+ id = rb_to_id(name);
+ rb_ary_unshift(rest, ID2SYM(id));
+ name = Qnil;
+ }
}
st = make_struct(name, rest, klass);
+ if (rb_block_given_p()) {
+ rb_mod_module_eval(0, 0, st);
+ }
return st;
}