diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | parse.y | 3 | ||||
-rw-r--r-- | test/ruby/test_literal.rb | 12 |
3 files changed, 15 insertions, 5 deletions
@@ -1,3 +1,8 @@ +Sat Feb 25 07:53:58 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (parser_tokadd_string): insert a backslash only if + quoted by single quotes. [ruby-dev:45281] [Bug #6069] + Sat Feb 25 07:53:49 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> * dir.c (dir_inspect), io.c (rb_io_inspect): keep encoding of path. @@ -6507,7 +6507,7 @@ parser_tokadd_string(struct parser_params *parser, default: if (c == -1) return -1; if (!ISASCII(c)) { - tokadd('\\'); + if ((func & STR_FUNC_EXPAND) == 0) tokadd('\\'); goto non_ascii; } if (func & STR_FUNC_REGEXP) { @@ -7597,7 +7597,6 @@ parser_yylex(struct parser_params *parser) } else if (!lex_eol_p() && !(c = *lex_p, ISASCII(c))) { nextc(); - tokadd('\\'); if (tokadd_mbchar(c) == -1) return 0; } else { diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb index bb3f50d2e5..e7a7c76891 100644 --- a/test/ruby/test_literal.rb +++ b/test/ruby/test_literal.rb @@ -79,9 +79,15 @@ class TestRubyLiteral < Test::Unit::TestCase assert_equal "\x13", "\c\x33" assert_equal "\x13", "\C-\x33" assert_equal "\xB3", "\M-\x33" - assert_equal "\\\u201c", eval(%["\\\u{201c}"]), bug6069 - assert_equal "\\\u201c".encode("euc-jp"), eval(%["\\\u{201c}"].encode("euc-jp")), bug6069 - assert_equal "\\\u201c".encode("iso-8859-13"), eval(%["\\\u{201c}"].encode("iso-8859-13")), bug6069 + assert_equal "\u201c", eval(%["\\\u{201c}"]), bug5262 + assert_equal "\u201c".encode("euc-jp"), eval(%["\\\u{201c}"].encode("euc-jp")), bug5262 + assert_equal "\u201c".encode("iso-8859-13"), eval(%["\\\u{201c}"].encode("iso-8859-13")), bug5262 + assert_equal "\\\u201c", eval(%['\\\u{201c}']), bug6069 + assert_equal "\\\u201c".encode("euc-jp"), eval(%['\\\u{201c}'].encode("euc-jp")), bug6069 + assert_equal "\\\u201c".encode("iso-8859-13"), eval(%['\\\u{201c}'].encode("iso-8859-13")), bug6069 + assert_equal "\u201c", eval(%[?\\\u{201c}]), bug6069 + assert_equal "\u201c".encode("euc-jp"), eval(%[?\\\u{201c}].encode("euc-jp")), bug6069 + assert_equal "\u201c".encode("iso-8859-13"), eval(%[?\\\u{201c}].encode("iso-8859-13")), bug6069 end def test_dstring |