ruby-changes:65631
From: Nobuyoshi <ko1@a...>
Date: Tue, 23 Mar 2021 17:48:43 +0900 (JST)
Subject: [ruby-changes:65631] 607aa11711 (master): Ignore useless separators preceding a file encoding comment
https://git.ruby-lang.org/ruby.git/commit/?id=607aa11711 From 607aa11711a7975540e1d71c2616ae5533feb35a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 23 Mar 2021 17:20:19 +0900 Subject: Ignore useless separators preceding a file encoding comment --- parse.y | 1 + test/ruby/test_parse.rb | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/parse.y b/parse.y index e24d26e..909a4ec 100644 --- a/parse.y +++ b/parse.y @@ -8274,6 +8274,7 @@ set_file_encoding(struct parser_params *p, const char *str, const char *send) https://github.com/ruby/ruby/blob/trunk/parse.y#L8274 continue; } if (STRNCASECMP(str-6, "coding", 6) == 0) break; + sep = 0; } for (;;) { do { diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 3f2deab..493042e 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -692,6 +692,14 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L692 x = __ENCODING__ END end + + assert_nothing_raised do + eval <<-END, nil, __FILE__, __LINE__+1 +# xxxx : coding sjis +x = __ENCODING__ + END + end + assert_equal(__ENCODING__, x) end def test_utf8_bom -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/