ruby-changes:20587
From: nobu <ko1@a...>
Date: Sat, 23 Jul 2011 12:19:16 +0900 (JST)
Subject: [ruby-changes:20587] nobu:r32635 (trunk): * parse.y (rb_check_id): take care of attrset ID created
nobu 2011-07-23 12:19:07 +0900 (Sat, 23 Jul 2011) New Revision: 32635 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32635 Log: * parse.y (rb_check_id): take care of attrset ID created implicitly by local ID. [Bug #5084] Modified files: trunk/ChangeLog trunk/parse.y Index: ChangeLog =================================================================== --- ChangeLog (revision 32634) +++ ChangeLog (revision 32635) @@ -1,5 +1,8 @@ -Sat Jul 23 12:12:25 2011 Nobuyoshi Nakada <nobu@r...> +Sat Jul 23 12:19:04 2011 Nobuyoshi Nakada <nobu@r...> + * parse.y (rb_check_id): take care of attrset ID created + implicitly by local ID. [Bug #5084] + * parse.y (rb_check_id): conversion condition was inverse. [Bug #5084] Index: parse.y =================================================================== --- parse.y (revision 32634) +++ parse.y (revision 32635) @@ -10120,9 +10120,33 @@ } name = tmp; } - if (!st_lookup(global_symbols.sym_id, (st_data_t)name, &id)) - return (ID)0; - return (ID)id; + + if (rb_enc_str_coderange(name) == ENC_CODERANGE_BROKEN) { + rb_raise(rb_eEncodingError, "invalid encoding symbol"); + } + + if (st_lookup(global_symbols.sym_id, (st_data_t)name, &id)) + return (ID)id; + + if (rb_is_attrset_name(name)) { + struct RString fake_str; + const VALUE localname = (VALUE)&fake_str; + /* make local name by chopping '=' */ + fake_str.basic.flags = T_STRING|RSTRING_NOEMBED; + fake_str.basic.klass = rb_cString; + fake_str.as.heap.len = RSTRING_LEN(name) - 1; + fake_str.as.heap.ptr = RSTRING_PTR(name); + fake_str.as.heap.aux.capa = fake_str.as.heap.len; + rb_enc_copy(localname, name); + OBJ_FREEZE(localname); + + if (st_lookup(global_symbols.sym_id, (st_data_t)localname, &id)) { + return rb_id_attrset((ID)id); + } + RB_GC_GUARD(name); + } + + return (ID)0; } int -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/