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

* parse.y (parser_tokadd_string, parser_yylex): insert a backslash

if the next character is non-ascii.  [ruby-dev:45278] [Bug #6069]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-02-23 23:52:12 +00:00
parent 455c23fa01
commit 45c6daeed7
3 changed files with 14 additions and 4 deletions

View file

@ -1,3 +1,8 @@
Fri Feb 24 08:52:09 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (parser_tokadd_string, parser_yylex): insert a backslash
if the next character is non-ascii. [ruby-dev:45278] [Bug #6069]
Fri Feb 24 08:13:20 2012 Eric Hodel <drbrain@segment7.net>
* lib/profiler.rb: Add Profiler documentation by Gonzalo Rodriguez.

View file

@ -6506,7 +6506,10 @@ parser_tokadd_string(struct parser_params *parser,
default:
if (c == -1) return -1;
if (!ISASCII(c)) goto non_ascii;
if (!ISASCII(c)) {
tokadd('\\');
goto non_ascii;
}
if (func & STR_FUNC_REGEXP) {
pushback(c);
if ((c = tokadd_escape(&enc)) < 0)
@ -7594,6 +7597,7 @@ 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 {

View file

@ -74,12 +74,13 @@ class TestRubyLiteral < Test::Unit::TestCase
end
end
end
bug6069 = '[ruby-dev:45278]'
assert_equal "\x13", "\c\x33"
assert_equal "\x13", "\C-\x33"
assert_equal "\xB3", "\M-\x33"
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
end
def test_dstring