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

ruby-changes:33400

From: nobu <ko1@a...>
Date: Mon, 31 Mar 2014 06:01:04 +0900 (JST)
Subject: [ruby-changes:33400] nobu:r45478 (trunk): process.c: preserve encodings

nobu	2014-03-31 06:00:53 +0900 (Mon, 31 Mar 2014)

  New Revision: 45478

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

  Log:
    process.c: preserve encodings
    
    * process.c (rlimit_resource_type, rlimit_resource_value):
      preserve argument encoding in error messages.

  Modified files:
    trunk/process.c
    trunk/test/ruby/test_process.rb
Index: process.c
===================================================================
--- process.c	(revision 45477)
+++ process.c	(revision 45478)
@@ -4527,7 +4527,7 @@ rlimit_resource_type(VALUE rtype) https://github.com/ruby/ruby/blob/trunk/process.c#L4527
     if (r != -1)
         return r;
 
-    rb_raise(rb_eArgError, "invalid resource name: %s", name);
+    rb_raise(rb_eArgError, "invalid resource name: %"PRIsVALUE, rtype);
 
     UNREACHABLE;
 }
@@ -4567,7 +4567,7 @@ rlimit_resource_value(VALUE rval) https://github.com/ruby/ruby/blob/trunk/process.c#L4567
 #ifdef RLIM_SAVED_CUR
     if (strcmp(name, "SAVED_CUR") == 0) return RLIM_SAVED_CUR;
 #endif
-    rb_raise(rb_eArgError, "invalid resource value: %s", name);
+    rb_raise(rb_eArgError, "invalid resource value: %"PRIsVALUE, rval);
 
     UNREACHABLE;
 }
Index: test/ruby/test_process.rb
===================================================================
--- test/ruby/test_process.rb	(revision 45477)
+++ test/ruby/test_process.rb	(revision 45478)
@@ -116,11 +116,15 @@ class TestProcess < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L116
     }
     assert_raise(ArgumentError) { Process.getrlimit(:FOO) }
     assert_raise(ArgumentError) { Process.getrlimit("FOO") }
+    assert_raise_with_message(ArgumentError, /\u{30eb 30d3 30fc}/) { Process.getrlimit("\u{30eb 30d3 30fc}") }
   end
 
   def test_rlimit_value
     return unless rlimit_exist?
+    assert_raise(ArgumentError) { Process.setrlimit(:FOO, 0) }
     assert_raise(ArgumentError) { Process.setrlimit(:CORE, :FOO) }
+    assert_raise_with_message(ArgumentError, /\u{30eb 30d3 30fc}/) { Process.setrlimit("\u{30eb 30d3 30fc}", 0) }
+    assert_raise_with_message(ArgumentError, /\u{30eb 30d3 30fc}/) { Process.setrlimit(:CORE, "\u{30eb 30d3 30fc}") }
     with_tmpchdir do
       s = run_in_child(<<-'End')
         cur, max = Process.getrlimit(:NOFILE)

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

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