mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 09:33:59 +02:00
merge revision(s) 54611,54612: [Backport #12291]
* struct.c (struct_make_members_list): extract making member name list from char* va_list, with creating symbols without intermediate IDs. * 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/branches/ruby_2_3@54637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
79e826d7f1
commit
9dc33b83bb
6 changed files with 99 additions and 34 deletions
24
ext/-test-/struct/duplicate.c
Normal file
24
ext/-test-/struct/duplicate.c
Normal file
|
@ -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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue