1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2014-10-06 03:08:48 +00:00
parent e14440e544
commit 986a893d7a

View file

@ -268,7 +268,8 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a
break; break;
case '[': case '[':
if (*++m != ']') return -1; if (m[1] != ']') goto id;
++m;
if (*++m == '=') ++m; if (*++m == '=') ++m;
break; 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; if (len == 1) return ID_JUNK;
switch (*++m) { switch (*++m) {
case '=': case '~': ++m; break; case '=': case '~': ++m; break;
default: return -1; default:
if (allowed_attrset & (1U << ID_JUNK)) goto id;
return -1;
} }
break; break;
default: default:
type = rb_enc_isupper(*m, enc) ? ID_CONST : ID_LOCAL; type = rb_enc_isupper(*m, enc) ? ID_CONST : ID_LOCAL;
id: 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; return -1;
}
while (m < e && is_identchar(m, e, enc)) m += rb_enc_mbclen(m, e, enc); while (m < e && is_identchar(m, e, enc)) m += rb_enc_mbclen(m, e, enc);
if (m >= e) break; if (m >= e) break;
switch (*m) { switch (*m) {