* parse.y (rb_check_id): take care of attrset ID created

implicitly by local ID.  [Bug #5084]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-07-23 03:19:07 +00:00
parent d9242d5966
commit 12d9be6b72
2 changed files with 31 additions and 4 deletions

View File

@ -1,4 +1,7 @@
Sat Jul 23 12:12:25 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
Sat Jul 23 12:19:04 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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]

30
parse.y
View File

@ -10120,9 +10120,33 @@ rb_check_id(VALUE name)
}
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