summaryrefslogtreecommitdiffstats
path: root/sprintf.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-03-20 17:01:30 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-03-20 17:01:30 +0000
commit9239b075e628acf18c4a6c4c1bd626aabdc312b8 (patch)
tree9ea99e238bb6bd42ebb923415696512ee85a4123 /sprintf.c
parentd095f16b52ca54c83966736c5188e01705c18158 (diff)
downloadruby-9239b075e628acf18c4a6c4c1bd626aabdc312b8.tar.gz
ruby-9239b075e628acf18c4a6c4c1bd626aabdc312b8.tar.xz
ruby-9239b075e628acf18c4a6c4c1bd626aabdc312b8.zip
* sprintf.c (rb_f_sprintf): copy sign bits only if value is
negative. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sprintf.c b/sprintf.c
index 69f9fa3ff..caea4c587 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -556,7 +556,12 @@ rb_f_sprintf(argc, argv)
}
}
else {
- char c = sign_bits(base, p);
+ char c;
+
+ if (bignum && !RBIGNUM(val)->sign)
+ c = sign_bits(base, p);
+ else
+ c = '0';
while (len < prec--) {
buf[blen++] = c;
}