summaryrefslogtreecommitdiff
path: root/ext/-test-
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-16 01:00:13 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-16 01:00:13 +0000
commitda2e0721b1ba94e8e786224469fe4bf7550c996a (patch)
tree6251858faae77bd6f9b9cfeaf71a5426906af6ab /ext/-test-
parentc746d5027d0a57ef5996b3394e7c6a2f2b96df0d (diff)
struct.c: unique members
* struct.c (struct_make_members_list, rb_struct_s_def): member names should be unique. [ruby-core:74971] [Bug #12291] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/-test-')
-rw-r--r--ext/-test-/struct/duplicate.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/ext/-test-/struct/duplicate.c b/ext/-test-/struct/duplicate.c
new file mode 100644
index 0000000..596d32a
--- /dev/null
+++ b/ext/-test-/struct/duplicate.c
@@ -0,0 +1,24 @@
+#include "ruby.h"
+
+static VALUE
+bug_struct_new_duplicate(VALUE obj, VALUE name, VALUE mem)
+{
+ const char *n = NIL_P(name) ? 0 : StringValueCStr(name);
+ const char *m = StringValueCStr(mem);
+ return rb_struct_define(n, m, m, NULL);
+}
+
+static VALUE
+bug_struct_new_duplicate_under(VALUE obj, VALUE name, VALUE mem)
+{
+ const char *n = StringValueCStr(name);
+ const char *m = StringValueCStr(mem);
+ return rb_struct_define_under(obj, n, m, m, NULL);
+}
+
+void
+Init_duplicate(VALUE klass)
+{
+ rb_define_singleton_method(klass, "new_duplicate", bug_struct_new_duplicate, 2);
+ rb_define_singleton_method(klass, "new_duplicate_under", bug_struct_new_duplicate_under, 2);
+}