Loading...
stdlib/OpenBSD/ecvt.c.patch Libc-763.12 Libc-498
--- Libc/Libc-763.12/stdlib/OpenBSD/ecvt.c.patch
+++ Libc/Libc-498/stdlib/OpenBSD/ecvt.c.patch
@@ -1,14 +1,18 @@
---- ecvt.c.orig	2009-11-06 00:43:00.000000000 -0800
-+++ ecvt.c	2009-11-06 00:45:11.000000000 -0800
+--- ecvt.c.orig	Thu Jul  8 16:06:45 2004
++++ ecvt.c	Fri Jul  9 12:23:51 2004
 @@ -20,6 +20,7 @@
   * Materiel Command, USAF, under agreement number F39502-99-1-0512.
   */
  
 +#include <sys/cdefs.h>
- #include <stdio.h>
- #include <stdlib.h>
+ #if defined(LIBC_SCCS) && !defined(lint)
+ static char rcsid[] = "$OpenBSD: ecvt.c,v 1.3 2003/06/17 21:56:24 millert Exp $";
+ #endif /* LIBC_SCCS and not lint */
+@@ -29,10 +30,11 @@
  #include <string.h>
-@@ -29,7 +30,7 @@ extern void  __freedtoa(char *);
+ 
+ extern char *__dtoa(double, int, int, int *, int *, char **);
++extern void __freedtoa(char *); /* special gdtoa free function */
  static char *__cvt(double, int, int *, int *, int, int);
  
  static char *
@@ -16,8 +20,31 @@
 +__cvt(double value, int ndigit, int * __restrict decpt, int * __restrict sign, int fmode, int pad)
  {
  	static char *s;
- 	char *p, *rve, c;
-@@ -95,13 +96,13 @@ __cvt(double value, int ndigit, int *dec
+ 	char *p, *rve;
+@@ -68,15 +70,20 @@
+ 		if (*decpt == 9999) {
+ 			/* Nan or Infinity */
+ 			*decpt = 0;
+-			return(p);
++			rve = (*p == 'N') ? "nan" : "inf";
++			__freedtoa(p);
++			return(rve);
+ 		}
+ 		/* make a local copy and adjust rve to be in terms of s */
+ 		if (pad && fmode)
+ 			siz += *decpt;
+-		if ((s = (char *)malloc(siz)) == NULL)
++		if ((s = (char *)malloc(siz)) == NULL) {
++			__freedtoa(p);
+ 			return(NULL);
++		}
+ 		(void) strlcpy(s, p, siz);
+ 		rve = s + (rve - p);
++		__freedtoa(p);
+ 	}
+ 
+ 	/* Add trailing zeros (unless we got NaN or Inf) */
+@@ -91,13 +98,13 @@
  }
  
  char *