зеркало из https://github.com/github/ruby.git
* missing/vsnprintf.c (BSD_vfprintf): fix for test_sprintf_comb.rb, by
wanabe in [ruby-dev:36935]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
941e77dc91
Коммит
3bad2b6ed9
|
@ -1,3 +1,8 @@
|
|||
Mon Dec 22 12:25:09 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* missing/vsnprintf.c (BSD_vfprintf): fix for test_sprintf_comb.rb, by
|
||||
wanabe in [ruby-dev:36935].
|
||||
|
||||
Mon Dec 22 12:05:14 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* configure.in (mingw): no longer uses snprintf and vsnprintf of
|
||||
|
|
|
@ -753,6 +753,8 @@ reswitch: switch (ch) {
|
|||
#ifdef FLOATING_POINT
|
||||
case 'e': /* anomalous precision */
|
||||
case 'E':
|
||||
if (prec != 0)
|
||||
flags |= ALT;
|
||||
prec = (prec == -1) ?
|
||||
DEFPREC + 1 : prec + 1;
|
||||
/* FALLTHROUGH */
|
||||
|
@ -782,7 +784,7 @@ fp_begin: _double = va_arg(ap, double);
|
|||
cp = cvt(_double, prec, flags, &softsign,
|
||||
&expt, ch, &ndig);
|
||||
if (ch == 'g' || ch == 'G') {
|
||||
if (expt <= -4 || expt > prec)
|
||||
if (expt <= -4 || (expt > prec && expt > 1))
|
||||
ch = (ch == 'g') ? 'e' : 'E';
|
||||
else
|
||||
ch = 'g';
|
||||
|
@ -798,6 +800,8 @@ fp_begin: _double = va_arg(ap, double);
|
|||
size = expt;
|
||||
if (prec || flags & ALT)
|
||||
size += prec + 1;
|
||||
} else if (!prec) { /* "0" */
|
||||
size = 1;
|
||||
} else /* "0.X" */
|
||||
size = prec + 2;
|
||||
} else if (expt >= ndig) { /* fixed g fmt */
|
||||
|
@ -1008,13 +1012,15 @@ number: if ((dprec = prec) >= 0)
|
|||
if (ch >= 'f') { /* 'f' or 'g' */
|
||||
if (_double == 0) {
|
||||
/* kludge for __dtoa irregularity */
|
||||
if (prec == 0 ||
|
||||
if (ndig <= 1 &&
|
||||
(flags & ALT) == 0) {
|
||||
PRINT("0", 1);
|
||||
} else {
|
||||
PRINT("0.", 2);
|
||||
PAD(ndig - 1, zeroes);
|
||||
}
|
||||
} else if (expt == 0 && ndig == 0 && (flags & ALT) == 0) {
|
||||
PRINT("0", 1);
|
||||
} else if (expt <= 0) {
|
||||
PRINT("0.", 2);
|
||||
PAD(-expt, zeroes);
|
||||
|
|
Загрузка…
Ссылка в новой задаче