summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--parse.y2
-rw-r--r--test/ruby/test_syntax.rb6
-rw-r--r--version.h2
4 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index b6f3a4d594..65f56116c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/parse.y b/parse.y
index 1ec06a3431..7da5e1e269 100644
--- a/parse.y
+++ b/parse.y
@@ -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
diff --git a/version.h b/version.h
index d5ad31efbe..8cb601b4af 100644
--- a/version.h
+++ b/version.h
@@ -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