diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | parse.y | 2 | ||||
-rw-r--r-- | test/ruby/test_syntax.rb | 6 |
3 files changed, 12 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Thu Aug 7 06:04:49 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (parser_yyerror): preserve source code encoding in + syntax error messages. [ruby-core:64228] [Bug #10114] + Wed Aug 6 20:56:02 2014 Masaki Suketa <masaki.suketa@nifty.ne.jp> * ext/win32ole/win32ole.c: separate src of WIN32OLE_TYPELIB from @@ -5261,7 +5261,7 @@ parser_yyerror(struct parser_params *parser, const char *msg) buf = ALLOCA_N(char, len+2); MEMCPY(buf, p, char, len); buf[len] = '\0'; - rb_compile_error_append("%s%s%s", pre, buf, post); + rb_compile_error_with_enc(NULL, 0, (void *)current_enc, "%s%s%s", pre, buf, post); i = (int)(lex_p - p); p2 = buf; pe = buf + len; diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index c20f85feea..1e988ddde7 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -435,6 +435,12 @@ eom assert_syntax_error("0.0.0", msg) end + def test_error_message_encoding + bug10114 = '[ruby-core:64228] [Bug #10114]' + code = "# -*- coding: utf-8 -*-\n" "def n \"\u{2208}\"; end" + assert_syntax_error(code, /def n "\u{2208}"; end/, bug10114) + end + private def not_label(x) @result = x; @not_label ||= nil end |