summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-12 03:09:28 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-12 03:09:28 +0000
commit174e3fb6e40e517275c0acf3cda0e991c47fa572 (patch)
tree27895cc300a7e446ad42aa839f934d0ca2efd8b3 /sprintf.c
parent7fa5e608d33d7b87763b37b4dc7793e2ae58c882 (diff)
* 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
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/sprintf.c b/sprintf.c
index 2b0fb82..b025b51 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] == '-') {