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

ruby-changes:29196

From: akr <ko1@a...>
Date: Wed, 12 Jun 2013 12:09:40 +0900 (JST)
Subject: [ruby-changes:29196] akr:r41248 (trunk): * sprintf.c (rb_str_format): Fix a dynamic format string.

akr	2013-06-12 12:09:28 +0900 (Wed, 12 Jun 2013)

  New Revision: 41248

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

  Log:
    * sprintf.c (rb_str_format): Fix a dynamic format string.

  Modified files:
    trunk/ChangeLog
    trunk/sprintf.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41247)
+++ ChangeLog	(revision 41248)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jun 12 12:07:04 2013  Tanaka Akira  <akr@f...>
+
+	* sprintf.c (rb_str_format): Fix a dynamic format string.
+
 Wed Jun 12 12:04:09 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* array.c (rb_ary_uniq_bang): must not be modified once frozen even in
Index: sprintf.c
===================================================================
--- sprintf.c	(revision 41247)
+++ sprintf.c	(revision 41248)
@@ -734,7 +734,7 @@ rb_str_format(int argc, const VALUE *arg https://github.com/ruby/ruby/blob/trunk/sprintf.c#L734
 	    {
 		volatile VALUE val = GETARG();
                 int valsign;
-		char fbuf[32], nbuf[64], *s;
+		char nbuf[64], *s;
 		const char *prefix = 0;
 		int sign = 0, dots = 0;
 		char sc = 0;
@@ -866,8 +866,6 @@ rb_str_format(int argc, const VALUE *arg https://github.com/ruby/ruby/blob/trunk/sprintf.c#L866
                     len = rb_long2int(RSTRING_END(tmp) - s);
                 }
                 else if (!bignum) {
-                    char c = *p;
-                    if (c == 'i') c = 'd'; /* %d and %i are identical */
                     valsign = 1;
                     if (v < 0) {
                         v = -v;
@@ -883,13 +881,12 @@ rb_str_format(int argc, const VALUE *arg https://github.com/ruby/ruby/blob/trunk/sprintf.c#L881
                         sc = ' ';
                         width--;
                     }
-                    snprintf(fbuf, sizeof(fbuf), "%%l%c", c);
-                    snprintf(nbuf, sizeof(nbuf), fbuf, v);
+                    snprintf(nbuf, sizeof(nbuf), "%ld", v);
                     s = nbuf;
 		    len = (int)strlen(s);
 		}
 		else {
-                    tmp = rb_big2str(val, base);
+                    tmp = rb_big2str(val, 10);
                     s = RSTRING_PTR(tmp);
                     valsign = 1;
                     if (s[0] == '-') {

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

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