diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-06 21:04:52 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-06 21:04:52 +0000 |
commit | 2bd1ae1e671822b8222c64c3e0d7241420330537 (patch) | |
tree | ef71d122d84394a748723c93068620c213a5c047 | |
parent | 2b14e2ae05231a675efe7898514b04f8d48b2ec2 (diff) |
parse.y: preserve encoding
* parse.y (parser_yyerror): preserve source code encoding in
syntax error messages. [ruby-core:64228] [Bug #10114]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-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 |