[前][次][番号順一覧][スレッド一覧]

ruby-changes:35734

From: nobu <ko1@a...>
Date: Mon, 6 Oct 2014 12:09:16 +0900 (JST)
Subject: [ruby-changes:35734] nobu:r47816 (trunk): symbol.c: junk-base attrset

nobu	2014-10-06 12:08:48 +0900 (Mon, 06 Oct 2014)

  New Revision: 47816

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47816

  Log:
    symbol.c: junk-base attrset
    
    * symbol.c (rb_enc_symname_type): allow junk-base attrset ID
      unless the stem is not an attrset name.

  Modified files:
    trunk/symbol.c
Index: symbol.c
===================================================================
--- symbol.c	(revision 47815)
+++ symbol.c	(revision 47816)
@@ -268,7 +268,8 @@ rb_enc_symname_type(const char *name, lo https://github.com/ruby/ruby/blob/trunk/symbol.c#L268
 	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, lo https://github.com/ruby/ruby/blob/trunk/symbol.c#L277
 	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) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]