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

ruby-changes:35294

From: nagachika <ko1@a...>
Date: Thu, 4 Sep 2014 00:26:06 +0900 (JST)
Subject: [ruby-changes:35294] nagachika:r47376 (ruby_2_1): merge revision(s) r46569: [Backport #9982]

nagachika	2014-09-04 00:25:51 +0900 (Thu, 04 Sep 2014)

  New Revision: 47376

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

  Log:
    merge revision(s) r46569: [Backport #9982]
    
    * sprintf.c (GETASTER): should not use the numbered argument to be
      formatted, raise ArgumentError instead.
      [ruby-dev:48330] [Bug #9982]

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/sprintf.c
    branches/ruby_2_1/test/ruby/test_sprintf.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 47375)
+++ ruby_2_1/ChangeLog	(revision 47376)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Thu Sep  4 00:23:15 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* sprintf.c (GETASTER): should not use the numbered argument to be
+	  formatted, raise ArgumentError instead.
+	  [ruby-dev:48330] [Bug #9982]
+
 Thu Sep  4 00:21:05 2014  SHIBATA Hiroshi  <shibata.hiroshi@g...>
 
 	* test/openssl/test_pkey_rsa.rb (OpenSSL#test_sign_verify_memory_leak):
Index: ruby_2_1/sprintf.c
===================================================================
--- ruby_2_1/sprintf.c	(revision 47375)
+++ ruby_2_1/sprintf.c	(revision 47376)
@@ -79,6 +79,9 @@ sign_bits(int base, const char *p) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/sprintf.c#L79
 } while (0)
 
 #define GETARG() (nextvalue != Qundef ? nextvalue : \
+		  GETNEXTARG())
+
+#define GETNEXTARG() ( \
     posarg == -1 ? \
     (rb_raise(rb_eArgError, "unnumbered(%d) mixed with numbered", nextarg), 0) : \
     posarg == -2 ? \
@@ -125,7 +128,7 @@ sign_bits(int base, const char *p) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/sprintf.c#L128
 	tmp = GETPOSARG(n); \
     } \
     else { \
-	tmp = GETARG(); \
+	tmp = GETNEXTARG(); \
 	p = t; \
     } \
     (val) = NUM2INT(tmp); \
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 47375)
+++ ruby_2_1/version.h	(revision 47376)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.2"
 #define RUBY_RELEASE_DATE "2014-09-04"
-#define RUBY_PATCHLEVEL 219
+#define RUBY_PATCHLEVEL 220
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 9
Index: ruby_2_1/test/ruby/test_sprintf.rb
===================================================================
--- ruby_2_1/test/ruby/test_sprintf.rb	(revision 47375)
+++ ruby_2_1/test/ruby/test_sprintf.rb	(revision 47376)
@@ -179,6 +179,10 @@ class TestSprintf < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_sprintf.rb#L179
     assert_raise(ArgumentError) { sprintf("%!", 1) }
     assert_raise(ArgumentError) { sprintf("%1$1$d", 1) }
     assert_raise(ArgumentError) { sprintf("%0%") }
+
+    assert_raise_with_message(ArgumentError, /unnumbered\(1\) mixed with numbered/) { sprintf("%1$*d", 3) }
+    assert_raise_with_message(ArgumentError, /unnumbered\(1\) mixed with numbered/) { sprintf("%1$.*d", 3) }
+
     verbose, $VERBOSE = $VERBOSE, nil
     assert_nothing_raised { sprintf("", 1) }
   ensure

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r46569


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

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