summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-23 03:19:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-23 03:19:07 +0000
commit12d9be6b727bdfe605fc65f18659c4cb4d4b283c (patch)
treeeb6f618c01646218c0a71343b217871ece11dd00
parentd9242d596658382cfc69c0a617ad167630d20687 (diff)
* 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
-rw-r--r--ChangeLog5
-rw-r--r--parse.y30
2 files changed, 31 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 7ebf45992a..69a691fd29 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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]
diff --git a/parse.y b/parse.y
index 9646350e2d..366090f903 100644
--- a/parse.y
+++ b/parse.y
@@ -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