Loading...
stdio/FreeBSD/vfprintf.c.patch Libc-583 Libc-498.1.7
--- Libc/Libc-583/stdio/FreeBSD/vfprintf.c.patch
+++ Libc/Libc-498.1.7/stdio/FreeBSD/vfprintf.c.patch
@@ -1,6 +1,6 @@
---- vfprintf.c.orig	2008-09-07 11:37:54.000000000 -0700
-+++ vfprintf.c	2008-09-07 17:33:16.000000000 -0700
-@@ -40,6 +40,8 @@ static char sccsid[] = "@(#)vfprintf.c	8
+--- vfprintf.c.orig	2006-10-01 00:03:16.000000000 -0700
++++ vfprintf.c	2006-10-01 00:21:05.000000000 -0700
+@@ -40,6 +40,8 @@
  #include <sys/cdefs.h>
  __FBSDID("$FreeBSD: src/lib/libc/stdio/vfprintf.c,v 1.68 2004/08/26 06:25:28 des Exp $");
  
@@ -9,7 +9,7 @@
  /*
   * Actual printf innards.
   *
-@@ -58,6 +60,7 @@ __FBSDID("$FreeBSD: src/lib/libc/stdio/v
+@@ -58,6 +60,7 @@
  #include <stdlib.h>
  #include <string.h>
  #include <wchar.h>
@@ -17,7 +17,7 @@
  
  #include <stdarg.h>
  #include "un-namespace.h"
-@@ -66,6 +69,13 @@ __FBSDID("$FreeBSD: src/lib/libc/stdio/v
+@@ -66,6 +69,13 @@
  #include "local.h"
  #include "fvwrite.h"
  
@@ -31,7 +31,7 @@
  union arg {
  	int	intarg;
  	u_int	uintarg;
-@@ -93,6 +103,21 @@ union arg {
+@@ -93,6 +103,21 @@
  #endif
  	wint_t	wintarg;
  	wchar_t	*pwchararg;
@@ -53,7 +53,7 @@
  };
  
  /*
-@@ -103,16 +128,20 @@ enum typeid {
+@@ -103,16 +128,20 @@
  	T_LONG, T_U_LONG, TP_LONG, T_LLONG, T_U_LLONG, TP_LLONG,
  	T_PTRDIFFT, TP_PTRDIFFT, T_SIZET, TP_SIZET,
  	T_INTMAXT, T_UINTMAXT, TP_INTMAXT, TP_VOID, TP_CHAR, TP_SCHAR,
@@ -76,7 +76,7 @@
  static void	__find_arguments(const char *, va_list, union arg **);
  static void	__grow_type_table(int, enum typeid **, int *);
  
-@@ -141,7 +170,7 @@ __sprint(FILE *fp, struct __suio *uio)
+@@ -141,7 +170,7 @@
   * worries about ungetc buffers and so forth.
   */
  static int
@@ -85,7 +85,7 @@
  {
  	int ret;
  	FILE fake;
-@@ -160,7 +189,7 @@ __sbprintf(FILE *fp, const char *fmt, va
+@@ -160,7 +189,7 @@
  	fake._lbfsize = 0;	/* not actually used, but Just In Case */
  
  	/* do the work, then copy any error status */
@@ -94,25 +94,7 @@
  	if (ret >= 0 && __fflush(&fake))
  		ret = EOF;
  	if (fake._flags & __SERR)
-@@ -252,7 +281,7 @@ __ultoa(u_long val, char *endp, int base
- 		break;
- 
- 	default:			/* oops */
--		abort();
-+		LIBC_ABORT("base = %d", base);
- 	}
- 	return (cp);
- }
-@@ -324,7 +353,7 @@ __ujtoa(uintmax_t val, char *endp, int b
- 		break;
- 
- 	default:
--		abort();
-+		LIBC_ABORT("base = %d", base);
- 	}
- 	return (cp);
- }
-@@ -336,14 +365,14 @@ __ujtoa(uintmax_t val, char *endp, int b
+@@ -336,14 +365,14 @@
   * that the wide char. string ends in a null character.
   */
  static char *
@@ -129,7 +111,7 @@
  
  	/*
  	 * Determine the number of bytes to output and allocate space for
-@@ -354,7 +383,7 @@ __wcsconv(wchar_t *wcsarg, int prec)
+@@ -354,7 +383,7 @@
  		p = wcsarg;
  		mbs = initial;
  		for (;;) {
@@ -138,7 +120,7 @@
  			if (clen == 0 || clen == (size_t)-1 ||
  			    nbytes + clen > prec)
  				break;
-@@ -363,7 +392,7 @@ __wcsconv(wchar_t *wcsarg, int prec)
+@@ -363,7 +392,7 @@
  	} else {
  		p = wcsarg;
  		mbs = initial;
@@ -147,7 +129,7 @@
  		if (nbytes == (size_t)-1)
  			return (NULL);
  	}
-@@ -378,7 +407,7 @@ __wcsconv(wchar_t *wcsarg, int prec)
+@@ -378,7 +407,7 @@
  	p = wcsarg;
  	mbs = initial;
  	while (mbp - convbuf < nbytes) {
@@ -156,7 +138,7 @@
  		if (clen == 0 || clen == (size_t)-1)
  			break;
  		mbp += clen;
-@@ -395,6 +424,8 @@ __wcsconv(wchar_t *wcsarg, int prec)
+@@ -395,6 +424,8 @@
  /*
   * MT-safe version
   */
@@ -165,7 +147,7 @@
  int
  vfprintf(FILE * __restrict fp, const char * __restrict fmt0, va_list ap)
  
-@@ -402,7 +433,21 @@ vfprintf(FILE * __restrict fp, const cha
+@@ -402,7 +433,21 @@
  	int ret;
  
  	FLOCKFILE(fp);
@@ -188,7 +170,7 @@
  	FUNLOCKFILE(fp);
  	return (ret);
  }
-@@ -451,12 +496,15 @@ static int exponent(char *, int, int);
+@@ -451,12 +496,15 @@
  #define	PTRDIFFT	0x800		/* ptrdiff_t */
  #define	INTMAXT		0x1000		/* intmax_t */
  #define	CHARINT		0x2000		/* print char using int format */
@@ -206,7 +188,7 @@
  {
  	char *fmt;		/* format string */
  	int ch;			/* character from fmt */
-@@ -502,6 +550,11 @@ __vfprintf(FILE *fp, const char *fmt0, v
+@@ -502,6 +550,11 @@
  	int nseps;		/* number of group separators with ' */
  	int nrepeats;		/* number of repeats of the last group */
  #endif
@@ -218,7 +200,7 @@
  	u_long	ulval;		/* integer arguments %[diouxX] */
  	uintmax_t ujval;	/* %j, %ll, %q, %t, %z integers */
  	int base;		/* base for [diouxX] conversion */
-@@ -599,13 +652,13 @@ __vfprintf(FILE *fp, const char *fmt0, v
+@@ -599,7 +652,7 @@
  #define	INTMAX_SIZE	(INTMAXT|SIZET|PTRDIFFT|LLONGINT)
  #define SJARG() \
  	(flags&INTMAXT ? GETARG(intmax_t) : \
@@ -227,14 +209,7 @@
  	    flags&PTRDIFFT ? (intmax_t)GETARG(ptrdiff_t) : \
  	    (intmax_t)GETARG(long long))
  #define	UJARG() \
- 	(flags&INTMAXT ? GETARG(uintmax_t) : \
- 	    flags&SIZET ? (uintmax_t)GETARG(size_t) : \
--	    flags&PTRDIFFT ? (uintmax_t)GETARG(ptrdiff_t) : \
-+	    flags&PTRDIFFT ? (uintmax_t)(unsigned)GETARG(ptrdiff_t) : \
- 	    (uintmax_t)GETARG(unsigned long long))
- 
- 	/*
-@@ -633,22 +686,24 @@ __vfprintf(FILE *fp, const char *fmt0, v
+@@ -633,22 +686,24 @@
  		val = GETARG (int); \
  	}
  
@@ -263,7 +238,7 @@
  
  	fmt = (char *)fmt0;
  	argtable = NULL;
-@@ -675,6 +730,9 @@ __vfprintf(FILE *fp, const char *fmt0, v
+@@ -675,6 +730,9 @@
  		}
  		if (ch == '\0')
  			goto done;
@@ -273,7 +248,7 @@
  		fmt++;		/* skip over '%' */
  
  		flags = 0;
-@@ -683,6 +741,9 @@ __vfprintf(FILE *fp, const char *fmt0, v
+@@ -683,6 +741,9 @@
  		prec = -1;
  		sign = '\0';
  		ox[1] = '\0';
@@ -283,7 +258,7 @@
  
  rflag:		ch = *fmt++;
  reswitch:	switch (ch) {
-@@ -698,6 +759,11 @@ reswitch:	switch (ch) {
+@@ -698,6 +759,11 @@
  		case '#':
  			flags |= ALT;
  			goto rflag;
@@ -295,7 +270,7 @@
  		case '*':
  			/*-
  			 * ``A negative field width argument is taken as a
-@@ -718,8 +784,8 @@ reswitch:	switch (ch) {
+@@ -718,8 +784,8 @@
  			goto rflag;
  		case '\'':
  			flags |= GROUPING;
@@ -306,7 +281,7 @@
  			goto rflag;
  		case '.':
  			if ((ch = *fmt++) == '*') {
-@@ -793,14 +859,18 @@ reswitch:	switch (ch) {
+@@ -793,14 +859,18 @@
  			flags |= LONGINT;
  			/*FALLTHROUGH*/
  		case 'c':
@@ -327,7 +302,7 @@
  				if (mbseqlen == (size_t)-1) {
  					fp->_flags |= __SERR;
  					goto error;
-@@ -817,6 +887,10 @@ reswitch:	switch (ch) {
+@@ -817,6 +887,10 @@
  			/*FALLTHROUGH*/
  		case 'd':
  		case 'i':
@@ -338,7 +313,7 @@
  			if (flags & INTMAX_SIZE) {
  				ujval = SJARG();
  				if ((intmax_t)ujval < 0) {
-@@ -835,6 +909,12 @@ reswitch:	switch (ch) {
+@@ -835,6 +909,12 @@
  #ifndef NO_FLOATING_POINT
  		case 'a':
  		case 'A':
@@ -351,7 +326,7 @@
  			if (ch == 'a') {
  				ox[1] = 'x';
  				xdigs = xdigs_lower;
-@@ -848,6 +928,12 @@ reswitch:	switch (ch) {
+@@ -848,6 +928,12 @@
  				prec++;
  			if (dtoaresult != NULL)
  				freedtoa(dtoaresult);
@@ -364,7 +339,7 @@
  			if (flags & LONGDBL) {
  				fparg.ldbl = GETARG(long double);
  				dtoaresult = cp =
-@@ -859,6 +945,7 @@ reswitch:	switch (ch) {
+@@ -859,6 +945,7 @@
  				    __hdtoa(fparg.dbl, xdigs, prec,
  				    &expt, &signflag, &dtoaend);
  			}
@@ -372,7 +347,7 @@
  			if (prec < 0)
  				prec = dtoaend - cp;
  			if (expt == INT_MAX)
-@@ -866,6 +953,12 @@ reswitch:	switch (ch) {
+@@ -866,6 +953,12 @@
  			goto fp_common;
  		case 'e':
  		case 'E':
@@ -385,7 +360,7 @@
  			expchar = ch;
  			if (prec < 0)	/* account for digit before decpt */
  				prec = DEFPREC + 1;
-@@ -874,10 +967,22 @@ reswitch:	switch (ch) {
+@@ -874,10 +967,22 @@
  			goto fp_begin;
  		case 'f':
  		case 'F':
@@ -408,7 +383,7 @@
  			expchar = ch - ('g' - 'e');
  			if (prec == 0)
  				prec = 1;
-@@ -886,6 +991,14 @@ fp_begin:
+@@ -886,6 +991,14 @@
  				prec = DEFPREC;
  			if (dtoaresult != NULL)
  				freedtoa(dtoaresult);
@@ -423,7 +398,7 @@
  			if (flags & LONGDBL) {
  				fparg.ldbl = GETARG(long double);
  				dtoaresult = cp =
-@@ -899,6 +1012,7 @@ fp_begin:
+@@ -899,6 +1012,7 @@
  				if (expt == 9999)
  					expt = INT_MAX;
  			}
@@ -431,7 +406,7 @@
  fp_common:
  			if (signflag)
  				sign = '-';
-@@ -993,6 +1107,10 @@ fp_common:
+@@ -993,6 +1107,10 @@
  			flags |= LONGINT;
  			/*FALLTHROUGH*/
  		case 'o':
@@ -442,7 +417,7 @@
  			if (flags & INTMAX_SIZE)
  				ujval = UJARG();
  			else
-@@ -1007,6 +1125,10 @@ fp_common:
+@@ -1007,6 +1125,10 @@
  			 * defined manner.''
  			 *	-- ANSI X3J11
  			 */
@@ -453,7 +428,7 @@
  			ujval = (uintmax_t)(uintptr_t)GETARG(void *);
  			base = 16;
  			xdigs = xdigs_lower;
-@@ -1025,7 +1147,7 @@ fp_common:
+@@ -1025,7 +1147,7 @@
  				if ((wcp = GETARG(wchar_t *)) == NULL)
  					cp = "(null)";
  				else {
@@ -462,7 +437,7 @@
  					if (convbuf == NULL) {
  						fp->_flags |= __SERR;
  						goto error;
-@@ -1056,6 +1178,10 @@ fp_common:
+@@ -1056,6 +1178,10 @@
  			flags |= LONGINT;
  			/*FALLTHROUGH*/
  		case 'u':
@@ -473,7 +448,7 @@
  			if (flags & INTMAX_SIZE)
  				ujval = UJARG();
  			else
-@@ -1068,6 +1194,10 @@ fp_common:
+@@ -1068,6 +1194,10 @@
  		case 'x':
  			xdigs = xdigs_lower;
  hex:
@@ -484,7 +459,7 @@
  			if (flags & INTMAX_SIZE)
  				ujval = UJARG();
  			else
-@@ -1093,6 +1223,7 @@ number:			if ((dprec = prec) >= 0)
+@@ -1093,6 +1223,7 @@
  			 * ``The result of converting a zero value with an
  			 * explicit precision of zero is no characters.''
  			 *	-- ANSI X3J11
@@ -492,7 +467,7 @@
  			 */
  			cp = buf + BUF;
  			if (flags & INTMAX_SIZE) {
-@@ -1102,7 +1233,7 @@ number:			if ((dprec = prec) >= 0)
+@@ -1102,7 +1233,7 @@
  					    flags & GROUPING, thousands_sep,
  					    grouping);
  			} else {
@@ -501,12 +476,9 @@
  					cp = __ultoa(ulval, cp, base,
  					    flags & ALT, xdigs,
  					    flags & GROUPING, thousands_sep,
-@@ -1110,8 +1241,13 @@ number:			if ((dprec = prec) >= 0)
- 			}
- 			size = buf + BUF - cp;
+@@ -1112,6 +1243,11 @@
  			if (size > BUF)	/* should never happen */
--				abort();
-+				LIBC_ABORT("size %d > BUF %d", size, BUF);
+ 				abort();
  			break;
 +#ifdef VECTORS
 +		case 'v':
@@ -516,7 +488,7 @@
  		default:	/* "%?" prints ?, unless ? is NUL */
  			if (ch == '\0')
  				goto done;
-@@ -1123,6 +1259,290 @@ number:			if ((dprec = prec) >= 0)
+@@ -1123,6 +1259,290 @@
  			break;
  		}
  
@@ -807,7 +779,7 @@
  		/*
  		 * All reasonable formats wind up here.  At this point, `cp'
  		 * points to a string which (if not flags&LADJUST) should be
-@@ -1178,7 +1598,7 @@ number:			if ((dprec = prec) >= 0)
+@@ -1178,7 +1598,7 @@
  				if (expt <= 0) {
  					PRINT(zeroes, 1);
  					if (prec || flags & ALT)
@@ -816,7 +788,7 @@
  					PAD(-expt, zeroes);
  					/* already handled initial 0's */
  					prec += expt;
-@@ -1203,14 +1623,14 @@ number:			if ((dprec = prec) >= 0)
+@@ -1203,14 +1623,14 @@
  							cp = dtoaend;
  					}
  					if (prec || flags & ALT)
@@ -834,7 +806,7 @@
  					PRINT(cp, ndig-1);
  					PAD(prec - ndig, zeroes);
  				} else	/* XeYYY */
-@@ -1406,6 +1826,11 @@ reswitch:	switch (ch) {
+@@ -1406,6 +1826,11 @@
  			if (flags & LONGINT)
  				ADDTYPE(T_WINT);
  			else
@@ -846,7 +818,7 @@
  				ADDTYPE(T_INT);
  			break;
  		case 'D':
-@@ -1413,6 +1838,11 @@ reswitch:	switch (ch) {
+@@ -1413,6 +1838,11 @@
  			/*FALLTHROUGH*/
  		case 'd':
  		case 'i':
@@ -858,7 +830,7 @@
  			ADDSARG();
  			break;
  #ifndef NO_FLOATING_POINT
-@@ -1421,8 +1851,14 @@ reswitch:	switch (ch) {
+@@ -1421,8 +1851,14 @@
  		case 'e':
  		case 'E':
  		case 'f':
@@ -873,7 +845,7 @@
  			if (flags & LONGDBL)
  				ADDTYPE(T_LONG_DOUBLE);
  			else
-@@ -1451,9 +1887,19 @@ reswitch:	switch (ch) {
+@@ -1451,9 +1887,19 @@
  			flags |= LONGINT;
  			/*FALLTHROUGH*/
  		case 'o':
@@ -893,7 +865,7 @@
  			ADDTYPE(TP_VOID);
  			break;
  		case 'S':
-@@ -1471,6 +1917,11 @@ reswitch:	switch (ch) {
+@@ -1471,6 +1917,11 @@
  		case 'u':
  		case 'X':
  		case 'x':
@@ -905,7 +877,7 @@
  			ADDUARG();
  			break;
  		default:	/* "%?" prints ?, unless ? is NUL */
-@@ -1537,7 +1988,7 @@ done:
+@@ -1537,7 +1988,7 @@
  			(*argtable) [n].sizearg = va_arg (ap, size_t);
  			break;
  		    case TP_SIZET:
@@ -914,7 +886,7 @@
  			break;
  		    case T_INTMAXT:
  			(*argtable) [n].intmaxarg = va_arg (ap, intmax_t);
-@@ -1556,6 +2007,11 @@ done:
+@@ -1556,6 +2007,11 @@
  			(*argtable) [n].longdoublearg = va_arg (ap, long double);
  			break;
  #endif
@@ -926,18 +898,3 @@
  		    case TP_CHAR:
  			(*argtable) [n].pchararg = va_arg (ap, char *);
  			break;
-@@ -1590,12 +2046,12 @@ __grow_type_table (int nextarg, enum typ
- 		newsize = nextarg + 1;
- 	if (oldsize == STATIC_ARG_TBL_SIZE) {
- 		if ((newtable = malloc(newsize * sizeof(enum typeid))) == NULL)
--			abort();			/* XXX handle better */
-+			LIBC_ABORT("malloc: %s", strerror(errno));			/* XXX handle better */
- 		bcopy(oldtable, newtable, oldsize * sizeof(enum typeid));
- 	} else {
- 		newtable = reallocf(oldtable, newsize * sizeof(enum typeid));
- 		if (newtable == NULL)
--			abort();			/* XXX handle better */
-+			LIBC_ABORT("reallocf: %s", strerror(errno));			/* XXX handle better */
- 	}
- 	for (n = oldsize; n < newsize; n++)
- 		newtable[n] = T_UNUSED;