diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-29 08:40:40 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-29 08:40:40 +0000 |
commit | d3fb88d09aea446e670eeab9864b333b22332451 (patch) | |
tree | 3e2fc873e8d25271f1a7e6f3f23635db112b55b3 | |
parent | 4a4a83c981b1f51f625073fbd63f8dc8a9f53044 (diff) |
merge revision(s) 51820: [Backport #11519]
* parse.y (literal_concat_gen, evstr2dstr_gen): keep literal
encoding beginning with an interpolation same as the source file
encoding. [ruby-core:70703] [Bug #11519]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | parse.y | 4 | ||||
-rw-r--r-- | test/ruby/test_literal.rb | 9 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 18 insertions, 3 deletions
@@ -1,3 +1,9 @@ +Tue Sep 29 17:39:42 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (literal_concat_gen, evstr2dstr_gen): keep literal + encoding beginning with an interpolation same as the source file + encoding. [ruby-core:70703] [Bug #11519] + Tue Sep 29 17:33:13 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> * lib/rss/rss.rb (Time#w3cdtf): fix zero-trimmed width of fraction @@ -8477,7 +8477,7 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail) htype = nd_type(head); if (htype == NODE_EVSTR) { - NODE *node = NEW_DSTR(Qnil); + NODE *node = NEW_DSTR(STR_NEW0()); head = list_append(node, head); htype = NODE_DSTR; } @@ -8550,7 +8550,7 @@ static NODE * evstr2dstr_gen(struct parser_params *parser, NODE *node) { if (nd_type(node) == NODE_EVSTR) { - node = list_append(NEW_DSTR(Qnil), node); + node = list_append(NEW_DSTR(STR_NEW0()), node); } return node; } diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb index 6e5d41477e..6e6831968d 100644 --- a/test/ruby/test_literal.rb +++ b/test/ruby/test_literal.rb @@ -103,6 +103,15 @@ class TestRubyLiteral < Test::Unit::TestCase assert_equal('FooBar', b, 'r3842') end + def test_dstring_encoding + bug11519 = '[ruby-core:70703] [Bug #11519]' + ['"foo#{}"', '"#{}foo"', '"#{}"'].each do |code| + a = eval("#-*- coding: utf-8 -*-\n#{code}") + assert_equal(Encoding::UTF_8, a.encoding, + proc{"#{bug11519}: #{code}.encoding"}) + end + end + def test_dsymbol assert_equal :a3c, :"a#{1+2}c" end @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.8" #define RUBY_RELEASE_DATE "2015-09-29" -#define RUBY_PATCHLEVEL 404 +#define RUBY_PATCHLEVEL 405 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 9 |