From 174e3fb6e40e517275c0acf3cda0e991c47fa572 Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 12 Jun 2013 03:09:28 +0000 Subject: [PATCH] * sprintf.c (rb_str_format): Fix a dynamic format string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ sprintf.c | 9 +++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5df3c64ad5..fef9134289 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Jun 12 12:07:04 2013 Tanaka Akira + + * sprintf.c (rb_str_format): Fix a dynamic format string. + Wed Jun 12 12:04:09 2013 Nobuyoshi Nakada * array.c (rb_ary_uniq_bang): must not be modified once frozen even in diff --git a/sprintf.c b/sprintf.c index 2b0fb823f2..b025b515ca 100644 --- a/sprintf.c +++ b/sprintf.c @@ -734,7 +734,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) { 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 *argv, VALUE fmt) 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 *argv, VALUE fmt) 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] == '-') {