aboutsummaryrefslogtreecommitdiffstats
path: root/symbol.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-06 03:08:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-06 03:08:48 +0000
commit986a893d7a420b8472c06b2e36b71b8bf00e9e21 (patch)
tree771506f89b88938135bf7c58b175457de2f01389 /symbol.c
parente14440e544be79d857f77dee2598ed98a8a6b59f (diff)
downloadruby-986a893d7a420b8472c06b2e36b71b8bf00e9e21.tar.gz
symbol.c: junk-base attrset
* symbol.c (rb_enc_symname_type): allow junk-base attrset ID unless the stem is not an attrset name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'symbol.c')
-rw-r--r--symbol.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/symbol.c b/symbol.c
index 6a1c0d351a..cc7da77ead 100644
--- a/symbol.c
+++ b/symbol.c
@@ -268,7 +268,8 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a
break;
case '[':
- if (*++m != ']') return -1;
+ if (m[1] != ']') goto id;
+ ++m;
if (*++m == '=') ++m;
break;
@@ -276,15 +277,22 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a
if (len == 1) return ID_JUNK;
switch (*++m) {
case '=': case '~': ++m; break;
- default: return -1;
+ default:
+ if (allowed_attrset & (1U << ID_JUNK)) goto id;
+ return -1;
}
break;
default:
type = rb_enc_isupper(*m, enc) ? ID_CONST : ID_LOCAL;
id:
- if (m >= e || (*m != '_' && !rb_enc_isalpha(*m, enc) && ISASCII(*m)))
+ if (m >= e || (*m != '_' && !rb_enc_isalpha(*m, enc) && ISASCII(*m))) {
+ if (len > 1 && *(e-1) == '=') {
+ type = rb_enc_symname_type(name, len-1, enc, allowed_attrset);
+ if (type != ID_ATTRSET) return ID_ATTRSET;
+ }
return -1;
+ }
while (m < e && is_identchar(m, e, enc)) m += rb_enc_mbclen(m, e, enc);
if (m >= e) break;
switch (*m) {