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

ruby-changes:33174

From: nagachika <ko1@a...>
Date: Mon, 3 Mar 2014 01:53:09 +0900 (JST)
Subject: [ruby-changes:33174] nagachika:r45253 (ruby_2_0_0): merge revision(s) r41598, r45181:

nagachika	2014-03-03 01:53:02 +0900 (Mon, 03 Mar 2014)

  New Revision: 45253

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

  Log:
    merge revision(s) r41598,r45181:
    
    * eval_error.c (warn_printf): use rb_vsprintf instead so ruby specific
      extensions like PRIsVALUE can be used in format strings
    
    * eval_error.c (error_print): use warn_print_str (alias for
      rb_write_error_str) to print a string value instead of using
      RSTRING_PTR and RSTRING_LEN manually
    
    * eval.c (setup_exception): use PRIsVALUE instead of %s and RSTRING_PTR
    
    * eval.c (setup_exception): preserve exception class name encoding
      in debug mode messages.

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/eval.c
    branches/ruby_2_0_0/eval_error.c
    branches/ruby_2_0_0/test/ruby/test_exception.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 45252)
+++ ruby_2_0_0/ChangeLog	(revision 45253)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Mon Mar  3 01:43:30 2014  Charlie Somerville  <charliesome@r...>
+
+	* eval_error.c (warn_printf): use rb_vsprintf instead so ruby specific
+	  extensions like PRIsVALUE can be used in format strings
+	* eval_error.c (error_print): use warn_print_str (alias for
+	  rb_write_error_str) to print a string value instead of using
+	  RSTRING_PTR and RSTRING_LEN manually
+	* eval.c (setup_exception): use PRIsVALUE instead of %s and RSTRING_PTR
+
 Mon Mar  3 01:32:14 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/readline/extconf.rb (rl_hook_func_t): define as Function for
Index: ruby_2_0_0/eval_error.c
===================================================================
--- ruby_2_0_0/eval_error.c	(revision 45252)
+++ ruby_2_0_0/eval_error.c	(revision 45253)
@@ -6,17 +6,18 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/eval_error.c#L6
 static void
 warn_printf(const char *fmt, ...)
 {
-    char buf[BUFSIZ];
+    VALUE str;
     va_list args;
 
     va_init_list(args, fmt);
-    vsnprintf(buf, BUFSIZ, fmt, args);
+    str = rb_vsprintf(fmt, args);
     va_end(args);
-    rb_write_error(buf);
+    rb_write_error_str(str);
 }
 
 #define warn_print(x) rb_write_error(x)
 #define warn_print2(x,l) rb_write_error2((x),(l))
+#define warn_print_str(x) rb_write_error_str(x)
 
 static void
 error_pos(void)
@@ -117,7 +118,7 @@ error_print(void) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/eval_error.c#L118
 	if (NIL_P(mesg))
 	    error_pos();
 	else {
-	    warn_print2(RSTRING_PTR(mesg), RSTRING_LEN(mesg));
+	    warn_print_str(mesg);
 	}
     }
 
@@ -143,7 +144,7 @@ error_print(void) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/eval_error.c#L144
 	epath = rb_class_name(eclass);
 	if (elen == 0) {
 	    warn_print(": ");
-	    warn_print2(RSTRING_PTR(epath), RSTRING_LEN(epath));
+	    warn_print_str(epath);
 	    warn_print("\n");
 	}
 	else {
@@ -160,7 +161,7 @@ error_print(void) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/eval_error.c#L161
 	    warn_print2(einfo, len);
 	    if (epath) {
 		warn_print(" (");
-		warn_print2(RSTRING_PTR(epath), RSTRING_LEN(epath));
+		warn_print_str(epath);
 		warn_print(")\n");
 	    }
 	    if (tail) {
@@ -182,7 +183,7 @@ error_print(void) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/eval_error.c#L183
 
 	for (i = 1; i < len; i++) {
 	    if (RB_TYPE_P(ptr[i], T_STRING)) {
-		warn_printf("\tfrom %s\n", RSTRING_PTR(ptr[i]));
+		warn_printf("\tfrom %"PRIsVALUE"\n", ptr[i]);
 	    }
 	    if (skip && i == TRACE_HEAD && len > TRACE_MAX) {
 		warn_printf("\t ... %ld levels...\n",
Index: ruby_2_0_0/eval.c
===================================================================
--- ruby_2_0_0/eval.c	(revision 45252)
+++ ruby_2_0_0/eval.c	(revision 45253)
@@ -474,19 +474,16 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/eval.c#L474
 	    e = rb_obj_as_string(mesg);
 	    th->errinfo = mesg;
 	    if (file && line) {
-		warn_printf("Exception `%s' at %s:%d - %s\n",
-			    rb_obj_classname(th->errinfo),
-			    file, line, RSTRING_PTR(e));
+		warn_printf("Exception `%"PRIsVALUE"' at %s:%d - %"PRIsVALUE"\n",
+			    rb_obj_class(mesg), file, line, e);
 	    }
 	    else if (file) {
-		warn_printf("Exception `%s' at %s - %s\n",
-			    rb_obj_classname(th->errinfo),
-			    file, RSTRING_PTR(e));
+		warn_printf("Exception `%"PRIsVALUE"' at %s - %"PRIsVALUE"\n",
+			    rb_obj_class(mesg), file, e);
 	    }
 	    else {
-		warn_printf("Exception `%s' - %s\n",
-			    rb_obj_classname(th->errinfo),
-			    RSTRING_PTR(e));
+		warn_printf("Exception `%"PRIsVALUE"' - %"PRIsVALUE"\n",
+			    rb_obj_class(mesg), e);
 	    }
 	}
 	POP_TAG();
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 45252)
+++ ruby_2_0_0/version.h	(revision 45253)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2014-03-03"
-#define RUBY_PATCHLEVEL 456
+#define RUBY_PATCHLEVEL 457
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_0_0/test/ruby/test_exception.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_exception.rb	(revision 45252)
+++ ruby_2_0_0/test/ruby/test_exception.rb	(revision 45253)
@@ -102,6 +102,23 @@ class TestException < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_exception.rb#L102
     assert_include(err, bug9568.to_s)
   end
 
+  def test_errinfo_encoding_in_debug
+    exc = Module.new {break class_eval("class C\u{30a8 30e9 30fc} < RuntimeError; self; end".encode(Encoding::EUC_JP))}
+    exc.inspect
+
+    err = EnvUtil.verbose_warning do
+      assert_raise(exc) do
+        $DEBUG, debug = true, $DEBUG
+        begin
+          raise exc
+        ensure
+          $DEBUG = debug
+        end
+      end
+    end
+    assert_include(err, exc.to_s)
+  end
+
   def test_break_ensure
     bad = true
     while true

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r41598,45181


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

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