diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | parse.y | 2 | ||||
-rw-r--r-- | test/ruby/test_syntax.rb | 6 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 13 insertions, 2 deletions
@@ -1,3 +1,8 @@ +Fri Sep 5 13:51:10 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (parser_yyerror): preserve source code encoding in + syntax error messages. [ruby-core:64228] [Bug #10114] + Fri Sep 5 13:44:53 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> * string.c (rb_str_count): fix wrong single-byte optimization. @@ -5246,7 +5246,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 3ccb18d446..bb13a4ed8c 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -352,6 +352,12 @@ eom assert_constant_reassignment_toplevel("11", "+", %w[53], already) 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 @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2014-09-05" -#define RUBY_PATCHLEVEL 551 +#define RUBY_PATCHLEVEL 552 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 9 |