ruby-changes:7913
From: naruse <ko1@a...>
Date: Sat, 20 Sep 2008 08:15:37 +0900 (JST)
Subject: [ruby-changes:7913] Ruby:r19434 (trunk): * parse.y: strings which contain only US-ASCII don't force to have
naruse 2008-09-20 08:09:33 +0900 (Sat, 20 Sep 2008) New Revision: 19434 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19434 Log: * parse.y: strings which contain only US-ASCII don't force to have US-ASCII encoding. [ruby-dev:36400] Modified files: trunk/ChangeLog trunk/parse.y trunk/test/ruby/test_m17n.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 19433) +++ ChangeLog (revision 19434) @@ -1,3 +1,8 @@ +Sat Sep 20 08:07:34 2008 NARUSE, Yui <naruse@r...> + + * parse.y: strings which contain only US-ASCII don't force to have + US-ASCII encoding. [ruby-dev:36400] + Sat Sep 20 07:59:31 2008 NARUSE, Yui <naruse@r...> * re.c (rb_reg_desc): Regexps of ASCII Compatible encoding may Index: parse.y =================================================================== --- parse.y (revision 19433) +++ parse.y (revision 19434) @@ -264,12 +264,11 @@ #define UTF8_ENC() (parser->utf8 ? parser->utf8 : \ (parser->utf8 = rb_utf8_encoding())) #define STR_NEW(p,n) rb_enc_str_new((p),(n),parser->enc) -#define STR_NEW0() rb_usascii_str_new(0,0) +#define STR_NEW0() rb_enc_str_new(0,0,parser->enc) #define STR_NEW2(p) rb_enc_str_new((p),strlen(p),parser->enc) #define STR_NEW3(p,n,e,func) parser_str_new((p),(n),(e),(func),parser->enc) -#define STR_ENC(m) ((m)?parser->enc:rb_usascii_encoding()) #define ENC_SINGLE(cr) ((cr)==ENC_CODERANGE_7BIT) -#define TOK_INTERN(mb) rb_intern3(tok(), toklen(), STR_ENC(mb)) +#define TOK_INTERN(mb) rb_intern3(tok(), toklen(), parser->enc) #ifdef YYMALLOC void *rb_parser_malloc(struct parser_params *, size_t); @@ -5150,7 +5149,6 @@ str = rb_enc_str_new(p, n, enc); if (!(func & STR_FUNC_REGEXP) && rb_enc_asciicompat(enc)) { if (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT) { - rb_enc_associate(str, rb_usascii_encoding()); } else if (enc0 == rb_usascii_encoding() && enc != rb_utf8_encoding()) { rb_enc_associate(str, rb_ascii8bit_encoding()); Index: test/ruby/test_m17n.rb =================================================================== --- test/ruby/test_m17n.rb (revision 19433) +++ test/ruby/test_m17n.rb (revision 19434) @@ -146,17 +146,17 @@ # tests start def test_string_ascii_literal - assert_encoding("US-ASCII", eval(a(%{""})).encoding) - assert_encoding("US-ASCII", eval(a(%{"a"})).encoding) + assert_encoding("ASCII-8BIT", eval(a(%{""})).encoding) + assert_encoding("ASCII-8BIT", eval(a(%{"a"})).encoding) end def test_string_eucjp_literal - assert_encoding("US-ASCII", eval(e(%{""})).encoding) - assert_encoding("US-ASCII", eval(e(%{"a"})).encoding) + assert_encoding("EUC-JP", eval(e(%{""})).encoding) + assert_encoding("EUC-JP", eval(e(%{"a"})).encoding) assert_encoding("EUC-JP", eval(e(%{"\xa1\xa1"})).encoding) assert_encoding("EUC-JP", eval(e(%{"\\xa1\\xa1"})).encoding) - assert_encoding("US-ASCII", eval(e(%{"\\x20"})).encoding) - assert_encoding("US-ASCII", eval(e(%{"\\n"})).encoding) + assert_encoding("EUC-JP", eval(e(%{"\\x20"})).encoding) + assert_encoding("EUC-JP", eval(e(%{"\\n"})).encoding) assert_encoding("EUC-JP", eval(e(%{"\\x80"})).encoding) end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/