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

ruby-changes:34483

From: nobu <ko1@a...>
Date: Thu, 26 Jun 2014 22:30:18 +0900 (JST)
Subject: [ruby-changes:34483] nobu:r46564 (trunk): sprintf.c: remove extra parentheses

nobu	2014-06-26 22:30:08 +0900 (Thu, 26 Jun 2014)

  New Revision: 46564

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

  Log:
    sprintf.c: remove extra parentheses
    
    * sprintf.c (GETASTER): remove extra parentheses from the second
      argument so that the error message does not contain them.

  Modified files:
    trunk/sprintf.c
    trunk/test/ruby/test_sprintf.rb
Index: sprintf.c
===================================================================
--- sprintf.c	(revision 46563)
+++ sprintf.c	(revision 46564)
@@ -120,7 +120,7 @@ sign_bits(int base, const char *p) https://github.com/ruby/ruby/blob/trunk/sprintf.c#L120
 #define GETASTER(val) do { \
     t = p++; \
     n = 0; \
-    GETNUM(n, (val)); \
+    GETNUM(n, val); \
     if (*p == '$') { \
 	tmp = GETPOSARG(n); \
     } \
Index: test/ruby/test_sprintf.rb
===================================================================
--- test/ruby/test_sprintf.rb	(revision 46563)
+++ test/ruby/test_sprintf.rb	(revision 46564)
@@ -309,6 +309,12 @@ class TestSprintf < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_sprintf.rb#L309
 
   def test_star
     assert_equal("-1 ", sprintf("%*d", -3, -1))
+    assert_raise_with_message(ArgumentError, /width too big/) {
+      sprintf("%*999999999999999999999999999999999999999999999999999999999999$d", 1)
+    }
+    assert_raise_with_message(ArgumentError, /prec too big/) {
+      sprintf("%.*999999999999999999999999999999999999999999999999999999999999$d", 1)
+    }
   end
 
   def test_escape

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

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