* vsnprintf.c (BSD_vfprintf): fix over-count of field size.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-10-19 03:19:30 +00:00
parent da55cfdf72
commit c511d26f6a
3 changed files with 7 additions and 2 deletions

View File

@ -1,3 +1,7 @@
Tue Oct 19 12:19:25 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vsnprintf.c (BSD_vfprintf): fix over-count of field size.
Tue Oct 19 03:08:52 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vsnprintf.c (BSD_vfprintf): use HEXPREFIX flag for prefix of %a.

View File

@ -219,6 +219,8 @@ class TestSprintf < Test::Unit::TestCase
assert_equal("-0x01.2p+0", sprintf("%010a", -1.125), bug3962)
assert_equal("-0x01.1p+0", sprintf("%010a", -1.0625), bug3962)
assert_equal("-0x1.08p+0", sprintf("%010a", -1.03125), bug3962)
assert_equal("0x000000000000001p+0", sprintf("%020a", 1), bug3962)
assert_equal("-0x00000000000001p+0", sprintf("%020a", -1), bug3962)
end
BSIZ = 120

View File

@ -831,7 +831,6 @@ fp_begin: _double = va_arg(ap, double);
expsize = exponent(expstr, expt, ch + 'p' - 'a');
ch += 'x' - 'a';
size = expsize + ndig;
size += 2; /* 0x */
if (ndig > 1)
++size; /* floating point */
}
@ -1028,7 +1027,7 @@ number: if ((dprec = prec) >= 0)
long_len:
if (sign)
fieldsz++;
else if (flags & HEXPREFIX)
if (flags & HEXPREFIX)
fieldsz += 2;
realsz = dprec > fieldsz ? dprec : fieldsz;