mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* vsnprintf.c (BSD_vfprintf): print floating point on "%#a".
[ruby-dev:42431] Bug#3965 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fb796561f0
commit
e9240114a0
3 changed files with 14 additions and 7 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Oct 20 10:00:57 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* vsnprintf.c (BSD_vfprintf): print floating point on "%#a".
|
||||||
|
[ruby-dev:42431] Bug#3965
|
||||||
|
|
||||||
Tue Oct 19 19:30:11 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
Tue Oct 19 19:30:11 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* vsnprintf.c (BSD_vfprintf): clear ALT flag for %a.
|
* vsnprintf.c (BSD_vfprintf): clear ALT flag for %a.
|
||||||
|
|
|
@ -221,10 +221,15 @@ class TestSprintf < Test::Unit::TestCase
|
||||||
assert_equal("-0x1.08p+0", sprintf("%010a", -1.03125), bug3962)
|
assert_equal("-0x1.08p+0", sprintf("%010a", -1.03125), bug3962)
|
||||||
|
|
||||||
bug3964 = '[ruby-core:32848]'
|
bug3964 = '[ruby-core:32848]'
|
||||||
assert_equal("0x000000000000000p+0", sprintf("%020a", 0), bug3962)
|
assert_equal("0x000000000000000p+0", sprintf("%020a", 0), bug3964)
|
||||||
assert_equal("0x000000000000001p+0", sprintf("%020a", 1), bug3964)
|
assert_equal("0x000000000000001p+0", sprintf("%020a", 1), bug3964)
|
||||||
assert_equal("-0x00000000000001p+0", sprintf("%020a", -1), bug3964)
|
assert_equal("-0x00000000000001p+0", sprintf("%020a", -1), bug3964)
|
||||||
assert_equal("0x000000000000000p+0", sprintf("%#020a", 0), bug3962)
|
assert_equal("0x00000000000000.p+0", sprintf("%#020a", 0), bug3964)
|
||||||
|
|
||||||
|
bug3965 = '[ruby-dev:42431]'
|
||||||
|
assert_equal("0x1.p+0", sprintf("%#.0a", 1), bug3965)
|
||||||
|
assert_equal("0x00000000000000.p+0", sprintf("%#020a", 0), bug3965)
|
||||||
|
assert_equal("0x0000.0000000000p+0", sprintf("%#020.10a", 0), bug3965)
|
||||||
end
|
end
|
||||||
|
|
||||||
BSIZ = 120
|
BSIZ = 120
|
||||||
|
|
|
@ -784,7 +784,6 @@ reswitch: switch (ch) {
|
||||||
#ifdef FLOATING_POINT
|
#ifdef FLOATING_POINT
|
||||||
case 'a':
|
case 'a':
|
||||||
case 'A':
|
case 'A':
|
||||||
flags &= ~ALT;
|
|
||||||
if (prec >= 0)
|
if (prec >= 0)
|
||||||
prec++;
|
prec++;
|
||||||
goto fp_begin;
|
goto fp_begin;
|
||||||
|
@ -832,7 +831,7 @@ fp_begin: _double = va_arg(ap, double);
|
||||||
expsize = exponent(expstr, expt, ch + 'p' - 'a');
|
expsize = exponent(expstr, expt, ch + 'p' - 'a');
|
||||||
ch += 'x' - 'a';
|
ch += 'x' - 'a';
|
||||||
size = expsize + ndig;
|
size = expsize + ndig;
|
||||||
if (ndig > 1)
|
if (ndig > 1 || flags & ALT)
|
||||||
++size; /* floating point */
|
++size; /* floating point */
|
||||||
}
|
}
|
||||||
else if (ch <= 'e') { /* 'e' or 'E' fmt */
|
else if (ch <= 'e') { /* 'e' or 'E' fmt */
|
||||||
|
@ -1067,7 +1066,7 @@ long_len:
|
||||||
ox[2] = *cp++;
|
ox[2] = *cp++;
|
||||||
ox[3] = '.';
|
ox[3] = '.';
|
||||||
PRINT(ox+2, 2);
|
PRINT(ox+2, 2);
|
||||||
PRINT(cp, ndig-1);
|
if (ndig > 0) PRINT(cp, ndig-1);
|
||||||
} else /* XpYYY */
|
} else /* XpYYY */
|
||||||
PRINT(cp, 1);
|
PRINT(cp, 1);
|
||||||
PRINT(expstr, expsize);
|
PRINT(expstr, expsize);
|
||||||
|
@ -1179,8 +1178,6 @@ cvt(value, ndigits, flags, sign, decpt, ch, length, buf)
|
||||||
*decpt = -ndigits + 1;
|
*decpt = -ndigits + 1;
|
||||||
bp += *decpt;
|
bp += *decpt;
|
||||||
}
|
}
|
||||||
if (value == 0) /* kludge for __dtoa irregularity */
|
|
||||||
rve = bp;
|
|
||||||
while (rve < bp)
|
while (rve < bp)
|
||||||
*rve++ = '0';
|
*rve++ = '0';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue