1 --- gcvt.c.orig Thu Jul 8 16:06:45 2004
2 +++ gcvt.c Fri Jul 9 12:16:25 2004
9 extern char *__dtoa(double, int, int, int *, int *, char **);
10 +extern void __freedtoa(char *);
13 gcvt(double value, int ndigit, char *buf)
15 char *digits, *dst, *src;
17 + char *decimal_point = localeconv()->decimal_point;
23 digits = __dtoa(value, 2, ndigit, &decpt, &sign, NULL);
25 - /* Infinity or NaN, assume buffer is at least ndigit long. */
26 - strlcpy(buf, digits, ndigit + 1);
27 + /* Infinity or NaN, assume buffer is long enough. */
31 + strcpy(dst, (*digits == 'N') ? "nan" : "inf");
40 - for (src = digits; *src != '\0'; )
43 + dst = stpcpy(dst, decimal_point);
44 + while (*src != '\0')
52 - for (sign = decpt, i = 0; (sign /= 10) != 0; i++)
54 + for (sign = decpt, i = 0; (sign /= 10) != 0; i++) {}
57 dst[i--] = '0' + decpt % 10;
63 - *dst++ = '.'; /* XXX - locale-specific (LC_NUMERIC) */
64 + if (src == digits) /* need leading zero */
66 + dst = stpcpy(dst, decimal_point);
67 for (i = decpt; digits[i] != '\0'; i++) {