Index: lib/libc/gdtoa/Makefile.inc =================================================================== RCS file: /cvs/src/lib/libc/gdtoa/Makefile.inc,v retrieving revision 1.2 diff -u -r1.2 Makefile.inc --- lib/libc/gdtoa/Makefile.inc 13 Mar 2003 18:55:14 -0000 1.2 +++ lib/libc/gdtoa/Makefile.inc 27 Mar 2003 06:57:27 -0000 @@ -3,7 +3,7 @@ # netlib gdtoa sources .PATH: ${.CURDIR}/gdtoa -MISRCS+=glue.c +MISRCS+=_ldtoa.c glue.c GDTOASRCS=dmisc.c dtoa.c gdtoa.c gethex.c gmisc.c \ hd_init.c hexnan.c misc.c smisc.c \ strtoIg.c strtod.c strtodg.c strtof.c strtord.c sum.c ulp.c Index: lib/libc/gdtoa/_ldtoa.c =================================================================== RCS file: lib/libc/gdtoa/_ldtoa.c diff -N lib/libc/gdtoa/_ldtoa.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lib/libc/gdtoa/_ldtoa.c 27 Mar 2003 09:57:01 -0000 @@ -0,0 +1,102 @@ +/*- + * Copyright (c) 2003 David Schultz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include "fpmath.h" +#include "gdtoaimp.h" + +/* + * ldtoa() is a wrapper for gdtoa() that makes it smell like dtoa(), + * except that the floating point argument is passed by reference. + * When dtoa() is passed a NaN or infinity, it sets expt to 9999. + * However, a long double could have a valid exponent of 9999, so we + * use INT_MAX in ldtoa() instead. + */ +char * +__ldtoa(long double *ld, int mode, int ndigits, int *decpt, int *sign, + char **rve) +{ + static FPI fpi = { + LDBL_MANT_DIG, /* nbits */ + LDBL_MIN_EXP - LDBL_MANT_DIG, /* emin */ + LDBL_MAX_EXP - LDBL_MANT_DIG, /* emax */ + FPI_Round_near, /* rounding */ +#ifdef Sudden_Underflow /* unused, but correct anyway */ + 1 +#else + 0 +#endif + }; + int be, kind; + char *ret; + union IEEEl2bits u; + uint32_t bits[(LDBL_MANT_DIG > 64) ? 4 : 2]; + + u.e = *ld; + *sign = u.bits.sign; + be = u.bits.exp - (LDBL_MAX_EXP - 1) - (LDBL_MANT_DIG - 1); +#if LDBL_MANT_DIG > 64 + bits[0] = (uint32_t)u.bits.manl; + bits[1] = (uint32_t)(u.bits.manl >> 32); + bits[2] = (uint32_t)u.bits.manh; + bits[3] = (uint32_t)(u.bits.manh >> 32); +#else + bits[0] = (uint32_t)u.bits.manl; + bits[1] = (uint32_t)u.bits.manh; +#endif + + switch (fpclassify(u.e)) { + case FP_NORMAL: + kind = STRTOG_Normal; + break; + case FP_ZERO: + kind = STRTOG_Zero; + break; + case FP_SUBNORMAL: + kind = STRTOG_Denormal; + break; + case FP_INFINITE: + kind = STRTOG_Infinite; + break; + case FP_NAN: + kind = STRTOG_NaN; + break; + default: + abort(); + } + + ret = gdtoa(&fpi, be, (ULong *)bits, &kind, mode, ndigits, decpt, rve); + if (*decpt == -32768) + *decpt = INT_MAX; + return ret; +} Index: lib/libc/stdio/floatio.h =================================================================== RCS file: /cvs/src/lib/libc/stdio/floatio.h,v retrieving revision 1.2 diff -u -r1.2 floatio.h --- lib/libc/stdio/floatio.h 22 Mar 2002 23:42:01 -0000 1.2 +++ lib/libc/stdio/floatio.h 27 Mar 2003 07:02:18 -0000 @@ -41,7 +41,16 @@ * Floating point scanf/printf (input/output) definitions. */ -/* 11-bit exponent (VAX G floating point) is 308 decimal digits */ -#define MAXEXP 308 -/* 128 bit fraction takes up 39 decimal digits; max reasonable precision */ -#define MAXFRACT 39 +/* + * MAXEXPDIG is the maximum number of decimal digits needed to store a + * floating point exponent in the largest supported format. It should + * be ceil(log10(LDBL_MAX_10_EXP)) or, if hexadecimal floating point + * conversions are supported, ceil(log10(LDBL_MAX_EXP)). But since it + * is presently never greater than 5 in practice, we fudge it. + */ +#define MAXEXPDIG 6 +#if LDBL_MAX_EXP > 999999 +#error "floating point buffers too small" +#endif + +char *__ldtoa(long double *, int, int, int *, int *, char **); Index: lib/libc/stdio/vfprintf.c =================================================================== RCS file: /cvs/src/lib/libc/stdio/vfprintf.c,v retrieving revision 1.52 diff -u -r1.52 vfprintf.c --- lib/libc/stdio/vfprintf.c 14 Mar 2003 04:48:09 -0000 1.52 +++ lib/libc/stdio/vfprintf.c 27 Mar 2003 15:31:12 -0000 @@ -111,9 +111,9 @@ static int __sprint(FILE *, struct __suio *); static int __sbprintf(FILE *, const char *, va_list) __printflike(2, 0); -static char *__ujtoa(uintmax_t, char *, int, int, char *, int, char, +static char *__ujtoa(uintmax_t, char *, int, int, const char *, int, char, const char *); -static char *__ultoa(u_long, char *, int, int, char *, int, char, +static char *__ultoa(u_long, char *, int, int, const char *, int, char, const char *); static char *__wcsconv(wchar_t *, int); static void __find_arguments(const char *, va_list, union arg **); @@ -185,7 +185,7 @@ * use the given digits. */ static char * -__ultoa(u_long val, char *endp, int base, int octzero, char *xdigs, +__ultoa(u_long val, char *endp, int base, int octzero, const char *xdigs, int needgrp, char thousep, const char *grp) { char *cp = endp; @@ -262,7 +262,7 @@ /* Identical to __ultoa, but for intmax_t. */ static char * -__ujtoa(uintmax_t val, char *endp, int base, int octzero, char *xdigs, +__ujtoa(uintmax_t val, char *endp, int base, int octzero, const char *xdigs, int needgrp, char thousep, const char *grp) { char *cp = endp; @@ -407,31 +407,36 @@ } #ifdef FLOATING_POINT + +#define dtoa __dtoa +#define freedtoa __freedtoa + +#include #include #include "floatio.h" +#include "gdtoa.h" -#define BUF ((MAXEXP*2)+MAXFRACT+1) /* + decimal point */ #define DEFPREC 6 -extern char *__dtoa(double, int, int, int *, int *, char **); -extern void __freedtoa(char *s); - -static char *cvt(double, int, int, char *, int *, int, int *); static int exponent(char *, int, int); -#else /* no FLOATING_POINT */ - -#define BUF 136 - #endif /* FLOATING_POINT */ +/* + * The size of the buffer we use as scratch space for integer + * conversions, among other things. + * + * XXX This should be MD, but 40 bytes should be sufficient until + * XXX sizeof(uintmax_t) > 16. + */ +#define BUF 40 + #define STATIC_ARG_TBL_SIZE 8 /* Size of static argument table. */ /* * Flags used during conversion. */ #define ALT 0x001 /* alternate form */ -#define HEXPREFIX 0x002 /* add 0x or 0X prefix */ #define LADJUST 0x004 /* left adjustment */ #define LONGDBL 0x008 /* long double */ #define LONGINT 0x010 /* long integer */ @@ -460,19 +465,41 @@ int flags; /* flags as above */ int ret; /* return value accumulator */ int width; /* width from format (%8d), or 0 */ - int prec; /* precision from format (%.3d), or -1 */ + int prec; /* precision from format; <0 for N/A */ char sign; /* sign prefix (' ', '+', '-', or \0) */ char thousands_sep; /* locale specific thousands separator */ const char *grouping; /* locale specific numeric grouping rules */ #ifdef FLOATING_POINT + /* + * We can decompose the printed representation of floating + * point numbers into several parts, some of which may be empty: + * + * [+|-| ] [0x|0X] MMM . NNN [e|E|p|P] [+|-] ZZ + * A B ---C--- D E F + * + * A: 'sign' holds this value if present; '\0' otherwise + * B: ox[1] holds the 'x' or 'X'; '\0' if not hexadecimal + * C: cp points to the string MMMNNN. Leading and trailing + * zeros are not in the string and must be added. + * D: expchar holds this character; '\0' if no exponent, e.g. %f + * F: at least two digits for decimal, at least one digit for hex + */ char *decimal_point; /* locale specific decimal point */ - char softsign; /* temporary negative sign for floats */ - double _double; /* double precision arguments %[eEfgG] */ + int signflag; /* true if float is negative */ + union { /* floating point arguments %[aAeEfFgG] */ + double dbl; + long double ldbl; + } fparg; int expt; /* integer value of exponent */ + char expchar; /* exponent character: [eEpP\0] */ + char *dtoaend; /* pointer to end of converted digits */ int expsize; /* character count for expstr */ - int ndig; /* actual number of digits returned by cvt */ - char expstr[7]; /* buffer for exponent string */ + int lead; /* sig figs before decimal or group sep */ + int ndig; /* actual number of digits returned by dtoa */ + char expstr[MAXEXPDIG+2]; /* buffer for exponent string: e+ZZZ */ char *dtoaresult; /* buffer allocated by dtoa */ + int nseps; /* number of group separators with ' */ + int nrepeats; /* number of repeats of the last group */ #endif u_long ulval; /* integer arguments %[diouxX] */ uintmax_t ujval; /* %j, %ll, %q, %t, %z integers */ @@ -481,12 +508,12 @@ int realsz; /* field size expanded by dprec, sign, etc */ int size; /* size of converted field or string */ int prsize; /* max size of printed field */ - char *xdigs; /* digits for [xX] conversion */ + const char *xdigs; /* digits for %[xX] conversion */ #define NIOV 8 struct __suio uio; /* output information: summary */ struct __siov iov[NIOV];/* ... and individual io vectors */ - char buf[BUF]; /* space for %c, %[diouxX], %[eEfFgG] */ - char ox[2]; /* space for 0x hex-prefix */ + char buf[BUF]; /* buffer with space for digits of intmax_t */ + char ox[2]; /* space for 0x; ox[1] is either x, X, or \0 */ union arg *argtable; /* args, built due to positional arg */ union arg statargtable [STATIC_ARG_TBL_SIZE]; int nextarg; /* 1-based argument index */ @@ -504,6 +531,9 @@ static char zeroes[PADSIZE] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'}; + static const char xdigs_lower[16] = "0123456789abcdef"; + static const char xdigs_upper[16] = "0123456789ABCDEF"; + /* * BEWARE, these `goto error' on error, and PAD uses `n'. */ @@ -643,6 +673,7 @@ width = 0; prec = -1; sign = '\0'; + ox[1] = '\0'; rflag: ch = *fmt++; reswitch: switch (ch) { @@ -797,86 +828,122 @@ #ifdef HEXFLOAT case 'a': case 'A': + if (ch == 'a') { + ox[1] = 'x'; + xdigs = xdigs_lower; + expchar = 'p'; + } else { + ox[1] = 'X'; + xdigs = xdigs_upper; + expchar = 'P'; + } + /* + * XXX We don't actually have a conversion + * XXX routine for this yet. + */ + if (flags & LONGDBL) { + fparg.ldbl = (double)GETARG(long double); + dtoaresult = cp = + __hldtoa(fparg.ldbl, xdigs, prec, + &expt, &signflag, &dtoaend); + } else { + fparg.dbl = GETARG(double); + dtoaresult = cp = + __hdtoa(fparg.dbl, xdigs, prec, + &expt, &signflag, &dtoaend); + } + goto fp_begin; #endif case 'e': case 'E': - /*- - * Grouping apply to %i, %d, %u, %f, %F, %g, %G - * conversion specifiers only. For other conversions - * behavior is undefined. - * -- POSIX - */ - flags &= ~GROUPING; - /*FALLTHROUGH*/ + expchar = ch; + if (prec < 0) /* account for digit before decpt */ + prec = DEFPREC + 1; + else + prec++; + goto fp_begin; case 'f': case 'F': + expchar = '\0'; goto fp_begin; case 'g': case 'G': + expchar = ch - ('g' - 'e'); if (prec == 0) prec = 1; -fp_begin: if (prec == -1) +fp_begin: + if (prec < 0) prec = DEFPREC; - if (flags & LONGDBL) - /* XXX this loses precision. */ - _double = (double)GETARG(long double); - else - _double = GETARG(double); - /* do this before tricky precision changes */ - if (isinf(_double)) { - if (_double < 0) - sign = '-'; - if (isupper(ch)) - cp = "INF"; - else - cp = "inf"; - size = 3; - break; + if (dtoaresult != NULL) + freedtoa(dtoaresult); + if (flags & LONGDBL) { + fparg.ldbl = GETARG(long double); + dtoaresult = cp = + __ldtoa(&fparg.ldbl, expchar ? 2 : 3, prec, + &expt, &signflag, &dtoaend); + } else { + fparg.dbl = GETARG(double); + dtoaresult = cp = + dtoa(fparg.dbl, expchar ? 2 : 3, prec, + &expt, &signflag, &dtoaend); + if (expt == 9999) + expt = INT_MAX; } - if (isnan(_double)) { - if (isupper(ch)) - cp = "NAN"; - else - cp = "nan"; + if (signflag) + sign = '-'; + if (expt == INT_MAX) { /* inf or nan */ + if (*cp == 'N') { + cp = (ch >= 'a') ? "nan" : "NAN"; + sign = '\0'; + } else + cp = (ch >= 'a') ? "inf" : "INF"; size = 3; break; } flags |= FPT; - if (dtoaresult != NULL) { - __freedtoa(dtoaresult); - dtoaresult = NULL; - } - dtoaresult = cp = cvt(_double, prec, flags, &softsign, - &expt, ch, &ndig); + ndig = dtoaend - cp; if (ch == 'g' || ch == 'G') { - if (expt <= -4 || expt > prec) - ch = (ch == 'g') ? 'e' : 'E'; - else - ch = 'g'; + if (expt > -4 && expt <= prec) { + /* Make %[gG] smell like %[fF] */ + expchar = '\0'; + if (flags & ALT) + prec -= expt; + else + prec = ndig - expt; + if (prec < 0) + prec = 0; + } } - if (ch == 'e' || ch == 'E') { - --expt; - expsize = exponent(expstr, expt, ch); - size = expsize + ndig; - if (ndig > 1 || flags & ALT) + if (expchar) { + expsize = exponent(expstr, expt - 1, expchar); + size = expsize + prec; + if (prec || flags & ALT) ++size; - } else if (ch == 'f' || ch == 'F') { + } else { if (expt > 0) { size = expt; if (prec || flags & ALT) size += prec + 1; } else /* "0.X" */ size = prec + 2; - } else if (expt >= ndig) { /* fixed g fmt */ - size = expt; - if (flags & ALT) - ++size; - } else - size = ndig + (expt > 0 ? - 1 : 2 - expt); - - if (softsign) - sign = '-'; + if (grouping && expt > 0) { + /* space for thousands' grouping */ + nseps = nrepeats = 0; + lead = expt; + while (*grouping != CHAR_MAX) { + if (lead <= *grouping) + break; + lead -= *grouping; + if (*(grouping+1)) { + nseps++; + grouping++; + } else + nrepeats++; + } + size += nseps + nrepeats; + } else + lead = (expt < ndig) ? expt : ndig; + } break; #endif /* FLOATING_POINT */ case 'n': @@ -922,9 +989,9 @@ */ ujval = (uintmax_t)(uintptr_t)GETARG(void *); base = 16; - xdigs = "0123456789abcdef"; - flags = flags | INTMAXT | HEXPREFIX; - ch = 'x'; + xdigs = xdigs_lower; + flags = flags | INTMAXT; + ox[1] = 'x'; goto nosign; case 'S': flags |= LONGINT; @@ -976,10 +1043,10 @@ base = 10; goto nosign; case 'X': - xdigs = "0123456789ABCDEF"; + xdigs = xdigs_upper; goto hex; case 'x': - xdigs = "0123456789abcdef"; + xdigs = xdigs_lower; hex: if (flags & INTMAX_SIZE) ujval = UJARG(); @@ -989,7 +1056,7 @@ /* leading 0x/X only if non-zero */ if (flags & ALT && (flags & INTMAX_SIZE ? ujval != 0 : ulval != 0)) - flags |= HEXPREFIX; + ox[1] = ch; flags &= ~GROUPING; /* unsigned conversions */ @@ -1022,6 +1089,8 @@ grouping); } size = buf + BUF - cp; + if (size > BUF) /* should never happen */ + abort(); break; default: /* "%?" prints ?, unless ? is NUL */ if (ch == '\0') @@ -1051,7 +1120,7 @@ realsz = dprec > size ? dprec : size; if (sign) realsz++; - else if (flags & HEXPREFIX) + else if (ox[1]) realsz += 2; prsize = width > realsz ? width : realsz; @@ -1067,9 +1136,8 @@ /* prefix */ if (sign) { PRINT(&sign, 1); - } else if (flags & HEXPREFIX) { + } else if (ox[1]) { /* ox[1] is either x, X, or \0 */ ox[0] = '0'; - ox[1] = ch; PRINT(ox, 2); } @@ -1085,42 +1153,49 @@ if ((flags & FPT) == 0) { PRINT(cp, size); } else { /* glue together f_p fragments */ - if (ch >= 'f') { /* 'f' or 'g' */ - if (_double == 0) { - /* kludge for __dtoa irregularity */ - PRINT("0", 1); - if (expt < ndig || (flags & ALT) != 0) { - PRINT(decimal_point, 1); - PAD(ndig - 1, zeroes); - } - } else if (expt <= 0) { - PRINT("0", 1); - PRINT(decimal_point, 1); + if (!expchar) { /* %[fF] or sufficiently short %[gG] */ + if (expt <= 0) { + buf[0] = '0'; + buf[1] = *decimal_point; + PRINT(buf, 2); PAD(-expt, zeroes); - PRINT(cp, ndig); - } else if (expt >= ndig) { - PRINT(cp, ndig); - PAD(expt - ndig, zeroes); - if (flags & ALT) - PRINT(decimal_point, 1); + if (ndig > 0) + PRINT(cp, ndig); } else { - PRINT(cp, expt); - cp += expt; - PRINT(decimal_point, 1); - PRINT(cp, ndig-expt); + PRINT(cp, lead); + cp += lead; + if (grouping) { + while (nseps>0 || nrepeats>0) { + if (nrepeats > 0) + nrepeats--; + else { + grouping--; + nseps--; + } + PRINT(&thousands_sep, + 1); + PRINT(cp, *grouping); + cp += *grouping; + } + } else { + PAD(expt - lead, zeroes); + } + if (prec || flags & ALT) + PRINT(decimal_point,1); + if (ndig > lead) + PRINT(cp, ndig - lead); } - } else { /* 'e' or 'E' */ - if (ndig > 1 || flags & ALT) { - ox[0] = *cp++; - ox[1] = *decimal_point; - PRINT(ox, 2); - if (_double) { - PRINT(cp, ndig-1); - } else /* 0.[0..] */ - /* __dtoa irregularity */ - PAD(ndig - 1, zeroes); + PAD(prec - ndig + expt, zeroes); + } else { /* %[eE] or sufficiently long %[gG] */ + if (prec || flags & ALT) { + buf[0] = *cp++; + buf[1] = *decimal_point; + PRINT(buf, 2); + PRINT(cp, ndig-1); + PAD(prec - ndig, zeroes); } else /* XeYYY */ PRINT(cp, 1); + PRINT(expstr, expsize); } } @@ -1141,7 +1216,7 @@ error: #ifdef FLOATING_POINT if (dtoaresult != NULL) - __freedtoa(dtoaresult); + freedtoa(dtoaresult); #endif if (convbuf != NULL) free(convbuf); @@ -1511,49 +1586,11 @@ #ifdef FLOATING_POINT -static char * -cvt(double value, int ndigits, int flags, char *sign, int *decpt, - int ch, int *length) -{ - int mode, dsgn; - char *digits, *bp, *rve; - - if (ch == 'f') - mode = 3; /* ndigits after the decimal point */ - else { - /* - * To obtain ndigits after the decimal point for the 'e' - * and 'E' formats, round to ndigits + 1 significant - * figures. - */ - if (ch == 'e' || ch == 'E') - ndigits++; - mode = 2; /* ndigits significant digits */ - } - digits = __dtoa(value, mode, ndigits, decpt, &dsgn, &rve); - *sign = dsgn != 0; - if ((ch != 'g' && ch != 'G') || flags & ALT) { - /* print trailing zeros */ - bp = digits + ndigits; - if (ch == 'f') { - if ((*digits == '0' || *digits == '\0') && value) - *decpt = -ndigits + 1; - bp += *decpt; - } - if (value == 0) /* kludge for __dtoa irregularity */ - rve = bp; - while (rve < bp) - *rve++ = '0'; - } - *length = rve - digits; - return (digits); -} - static int exponent(char *p0, int exp, int fmtch) { char *p, *t; - char expbuf[MAXEXP]; + char expbuf[MAXEXPDIG]; p = p0; *p++ = fmtch; @@ -1563,16 +1600,23 @@ } else *p++ = '+'; - t = expbuf + MAXEXP; + t = expbuf + MAXEXPDIG; if (exp > 9) { do { *--t = to_char(exp % 10); } while ((exp /= 10) > 9); *--t = to_char(exp); - for (; t < expbuf + MAXEXP; *p++ = *t++); + for (; t < expbuf + MAXEXPDIG; *p++ = *t++); } else { - *p++ = '0'; + /* + * Exponents for decimal floating point conversions + * (%[eEgG]) must be at least two characters long, + * whereas exponents for hexadecimal conversions can + * be only one character long. + */ + if (fmtch == 'e' || fmtch == 'E') + *p++ = '0'; *p++ = to_char(exp); } return (p - p0); Index: lib/libc/stdio/vfwprintf.c =================================================================== RCS file: /cvs/src/lib/libc/stdio/vfwprintf.c,v retrieving revision 1.7 diff -u -r1.7 vfwprintf.c --- lib/libc/stdio/vfwprintf.c 14 Mar 2003 08:50:43 -0000 1.7 +++ lib/libc/stdio/vfwprintf.c 27 Mar 2003 15:31:08 -0000 @@ -400,10 +400,10 @@ } #ifdef FLOATING_POINT +#include #include #include "floatio.h" -#define BUF ((MAXEXP*2)+MAXFRACT+1) /* + decimal point */ #define DEFPREC 6 extern char *__dtoa(double, int, int, int *, int *, char **); @@ -412,12 +412,10 @@ static wchar_t *cvt(double, int, int, char *, int *, wchar_t, int *); static int exponent(wchar_t *, int, wchar_t); -#else /* no FLOATING_POINT */ +#endif /* FLOATING_POINT */ #define BUF 136 -#endif /* FLOATING_POINT */ - #define STATIC_ARG_TBL_SIZE 8 /* Size of static argument table. */ /* @@ -1524,7 +1522,7 @@ exponent(wchar_t *p0, int exp, wchar_t fmtch) { wchar_t *p, *t; - wchar_t expbuf[MAXEXP]; + wchar_t expbuf[MAXEXPDIG]; p = p0; *p++ = fmtch; @@ -1534,13 +1532,13 @@ } else *p++ = '+'; - t = expbuf + MAXEXP; + t = expbuf + MAXEXPDIG; if (exp > 9) { do { *--t = to_char(exp % 10); } while ((exp /= 10) > 9); *--t = to_char(exp); - for (; t < expbuf + MAXEXP; *p++ = *t++); + for (; t < expbuf + MAXEXPDIG; *p++ = *t++); } else { *p++ = '0'; Index: contrib/gdtoa/gdtoaimp.h =================================================================== RCS file: /cvs/src/contrib/gdtoa/gdtoaimp.h,v retrieving revision 1.3 diff -u -r1.3 gdtoaimp.h --- contrib/gdtoa/gdtoaimp.h 19 Mar 2003 20:25:45 -0000 1.3 +++ contrib/gdtoa/gdtoaimp.h 27 Mar 2003 07:47:42 -0000 @@ -600,6 +600,8 @@ extern Bigint *diff ANSI((Bigint*, Bigint*)); extern char *dtoa ANSI((double d, int mode, int ndigits, int *decpt, int *sign, char **rve)); + extern char *gdtoa ANSI((FPI *fpi, int be, ULong *bits, int *kindp, + int mode, int ndigits, int *decpt, char **rve)); extern char *g__fmt ANSI((char*, char*, char*, int, ULong)); extern int gethex ANSI((CONST char**, FPI*, Long*, Bigint**, int)); extern void hexdig_init_D2A(Void);