[前][次][番号順一覧][スレッド一覧]

ruby-changes:35008

From: nobu <ko1@a...>
Date: Thu, 7 Aug 2014 06:05:20 +0900 (JST)
Subject: [ruby-changes:35008] nobu:r47090 (trunk): parse.y: preserve encoding

nobu	2014-08-07 06:04:52 +0900 (Thu, 07 Aug 2014)

  New Revision: 47090

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47090

  Log:
    parse.y: preserve encoding
    
    * parse.y (parser_yyerror): preserve source code encoding in
      syntax error messages.  [ruby-core:64228] [Bug #10114]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/test/ruby/test_syntax.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47089)
+++ ChangeLog	(revision 47090)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Aug  7 06:04:49 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@n...>
 
 	* ext/win32ole/win32ole.c: separate src of WIN32OLE_TYPELIB from
Index: parse.y
===================================================================
--- parse.y	(revision 47089)
+++ parse.y	(revision 47090)
@@ -5261,7 +5261,7 @@ parser_yyerror(struct parser_params *par https://github.com/ruby/ruby/blob/trunk/parse.y#L5261
 	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;
Index: test/ruby/test_syntax.rb
===================================================================
--- test/ruby/test_syntax.rb	(revision 47089)
+++ test/ruby/test_syntax.rb	(revision 47090)
@@ -435,6 +435,12 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L435
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]