]> git.saurik.com Git - apple/libc.git/blob - stdlib/OpenBSD/ecvt.c.patch
Libc-391.4.1.tar.gz
[apple/libc.git] / stdlib / OpenBSD / ecvt.c.patch
1 --- ecvt.c.orig Thu Jul 8 16:06:45 2004
2 +++ ecvt.c Fri Jul 9 12:23:51 2004
3 @@ -20,6 +20,7 @@
4 * Materiel Command, USAF, under agreement number F39502-99-1-0512.
5 */
6
7 +#include <sys/cdefs.h>
8 #if defined(LIBC_SCCS) && !defined(lint)
9 static char rcsid[] = "$OpenBSD: ecvt.c,v 1.3 2003/06/17 21:56:24 millert Exp $";
10 #endif /* LIBC_SCCS and not lint */
11 @@ -29,10 +30,11 @@
12 #include <string.h>
13
14 extern char *__dtoa(double, int, int, int *, int *, char **);
15 +extern void __freedtoa(char *); /* special gdtoa free function */
16 static char *__cvt(double, int, int *, int *, int, int);
17
18 static char *
19 -__cvt(double value, int ndigit, int *decpt, int *sign, int fmode, int pad)
20 +__cvt(double value, int ndigit, int * __restrict decpt, int * __restrict sign, int fmode, int pad)
21 {
22 static char *s;
23 char *p, *rve;
24 @@ -68,15 +70,20 @@
25 if (*decpt == 9999) {
26 /* Nan or Infinity */
27 *decpt = 0;
28 - return(p);
29 + rve = (*p == 'N') ? "nan" : "inf";
30 + __freedtoa(p);
31 + return(rve);
32 }
33 /* make a local copy and adjust rve to be in terms of s */
34 if (pad && fmode)
35 siz += *decpt;
36 - if ((s = (char *)malloc(siz)) == NULL)
37 + if ((s = (char *)malloc(siz)) == NULL) {
38 + __freedtoa(p);
39 return(NULL);
40 + }
41 (void) strlcpy(s, p, siz);
42 rve = s + (rve - p);
43 + __freedtoa(p);
44 }
45
46 /* Add trailing zeros (unless we got NaN or Inf) */
47 @@ -91,13 +98,13 @@
48 }
49
50 char *
51 -ecvt(double value, int ndigit, int *decpt, int *sign)
52 +ecvt(double value, int ndigit, int * __restrict decpt, int * __restrict sign)
53 {
54 return(__cvt(value, ndigit, decpt, sign, 0, 1));
55 }
56
57 char *
58 -fcvt(double value, int ndigit, int *decpt, int *sign)
59 +fcvt(double value, int ndigit, int * __restrict decpt, int * __restrict sign)
60 {
61 return(__cvt(value, ndigit, decpt, sign, 1, 1));
62 }