Loading...
stdio/FreeBSD/vfprintf.c.patch Libc-391 Libc-320.1.3
--- Libc/Libc-391/stdio/FreeBSD/vfprintf.c.patch
+++ Libc/Libc-320.1.3/stdio/FreeBSD/vfprintf.c.patch
@@ -1,15 +1,6 @@
---- vfprintf.c.orig	2004-11-25 11:38:35.000000000 -0800
-+++ vfprintf.c	2005-02-24 15:16:20.000000000 -0800
-@@ -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 $");
- 
-+#include "xlocale_private.h"
-+
- /*
-  * Actual printf innards.
-  *
-@@ -58,6 +60,7 @@
+--- vfprintf.c.orig	Thu Jul 24 12:42:14 2003
++++ vfprintf.c	Tue Apr  6 17:44:49 2004
+@@ -58,6 +58,7 @@
  #include <stdlib.h>
  #include <string.h>
  #include <wchar.h>
@@ -17,20 +8,37 @@
  
  #include <stdarg.h>
  #include "un-namespace.h"
-@@ -66,6 +69,12 @@
+@@ -66,9 +67,20 @@
  #include "local.h"
  #include "fvwrite.h"
  
 +#ifdef ALTIVEC
 +#include <machine/cpu_capabilities.h>
 +
-+#define VECTORTYPE    vector unsigned char
-+#endif /* ALTIVEC */
++#define VECTORTYPE	vector unsigned char
++#endif /* ALTIVEC */
++
+ /* Define FLOATING_POINT to get floating point. */
+ #define	FLOATING_POINT
+ 
++/* if no floating point, turn off HEXFLOAT as well */
++#if defined(HEXFLOAT) && !defined(FLOATING_POINT)
++#undef HEXFLOAT
++#endif /* defined(HEXFLOAT) && !defined(FLOATING_POINT) */
 +
  union arg {
  	int	intarg;
  	u_int	uintarg;
-@@ -93,6 +102,16 @@
+@@ -88,7 +100,7 @@
+ 	long	*plongarg;
+ 	long long *plonglongarg;
+ 	ptrdiff_t *pptrdiffarg;
+-	size_t	*psizearg;
++	ssize_t	*psizearg;
+ 	intmax_t *pintmaxarg;
+ #ifdef FLOATING_POINT
+ 	double	doublearg;
+@@ -96,6 +108,16 @@
  #endif
  	wint_t	wintarg;
  	wchar_t	*pwchararg;
@@ -47,7 +55,7 @@
  };
  
  /*
-@@ -103,19 +122,56 @@
+@@ -106,7 +128,11 @@
  	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,
@@ -59,14 +67,7 @@
  };
  
  static int	__sprint(FILE *, struct __suio *);
--static int	__sbprintf(FILE *, const char *, va_list) __printflike(2, 0);
-+static int	__sbprintf(FILE *, locale_t, const char *, va_list) __printflike(3, 0);
- static char	*__ujtoa(uintmax_t, char *, int, int, const char *, int, char,
- 		    const char *);
- static char	*__ultoa(u_long, char *, int, int, const char *, int, char,
- 		    const char *);
--static char	*__wcsconv(wchar_t *, int);
-+static char	*__wcsconv(wchar_t *, int, locale_t);
+@@ -119,6 +145,37 @@
  static void	__find_arguments(const char *, va_list, union arg **);
  static void	__grow_type_table(int, enum typeid **, int *);
  
@@ -87,8 +88,6 @@
 + * processor would crash on illegal instruction.  By isolating the calling
 + * sequence in getvec(), __vprintf() is callable by a non-Altivec processor.
 + *-----------------------------------------------------------------------*/
-+static va_list getvec(union arg *, const union arg *, int, va_list) __attribute__((noinline));
-+
 +static va_list
 +getvec(union arg *dst, const union arg *argtable, int nextarg, va_list ap)
 +{
@@ -106,84 +105,23 @@
  /*
   * Flush out all the vectors defined by the given uio,
   * then reset it so that it can be reused.
-@@ -141,7 +197,7 @@
-  * worries about ungetc buffers and so forth.
-  */
- static int
--__sbprintf(FILE *fp, const char *fmt, va_list ap)
-+__sbprintf(FILE *fp, locale_t loc, const char *fmt, va_list ap)
- {
- 	int ret;
- 	FILE fake;
-@@ -160,7 +216,7 @@
- 	fake._lbfsize = 0;	/* not actually used, but Just In Case */
- 
- 	/* do the work, then copy any error status */
--	ret = __vfprintf(&fake, fmt, ap);
-+	ret = __vfprintf(&fake, loc, fmt, ap);
- 	if (ret >= 0 && __fflush(&fake))
- 		ret = EOF;
- 	if (fake._flags & __SERR)
-@@ -336,7 +392,7 @@
-  * that the wide char. string ends in a null character.
-  */
- static char *
--__wcsconv(wchar_t *wcsarg, int prec)
-+__wcsconv(wchar_t *wcsarg, int prec, locale_t loc)
- {
- 	static const mbstate_t initial;
- 	mbstate_t mbs;
-@@ -354,7 +410,7 @@
- 		p = wcsarg;
- 		mbs = initial;
- 		for (;;) {
--			clen = wcrtomb(buf, *p++, &mbs);
-+			clen = wcrtomb_l(buf, *p++, &mbs, loc);
- 			if (clen == 0 || clen == (size_t)-1 ||
- 			    nbytes + clen > prec)
- 				break;
-@@ -363,7 +419,7 @@
- 	} else {
- 		p = wcsarg;
- 		mbs = initial;
--		nbytes = wcsrtombs(NULL, (const wchar_t **)&p, 0, &mbs);
-+		nbytes = wcsrtombs_l(NULL, (const wchar_t **)&p, 0, &mbs, loc);
- 		if (nbytes == (size_t)-1)
- 			return (NULL);
- 	}
-@@ -378,7 +434,7 @@
- 	p = wcsarg;
- 	mbs = initial;
- 	while (mbp - convbuf < nbytes) {
--		clen = wcrtomb(mbp, *p++, &mbs);
-+		clen = wcrtomb_l(mbp, *p++, &mbs, loc);
- 		if (clen == 0 || clen == (size_t)-1)
- 			break;
- 		mbp += clen;
-@@ -402,7 +458,21 @@
- 	int ret;
- 
- 	FLOCKFILE(fp);
--	ret = __vfprintf(fp, fmt0, ap);
-+	ret = __vfprintf(fp, __current_locale(), fmt0, ap);
-+	FUNLOCKFILE(fp);
-+	return (ret);
-+}
-+
-+int
-+vfprintf_l(FILE * __restrict fp, locale_t loc, const char * __restrict fmt0,
-+    va_list ap)
-+
-+{
-+	int ret;
-+
-+	NORMALIZE_LOCALE(loc);
-+	FLOCKFILE(fp);
-+	ret = __vfprintf(fp, loc, fmt0, ap);
- 	FUNLOCKFILE(fp);
- 	return (ret);
- }
-@@ -451,12 +521,15 @@
+@@ -424,6 +481,15 @@
+ 
+ #endif /* FLOATING_POINT */
+ 
++#ifdef HEXFLOAT
++extern int __hdtoa(double d, const char *xdigs, int prec, char *cp,
++    int *expt, int *signflag, char **dtoaend);
++#if !__TYPE_LONGDOUBLE_IS_DOUBLE
++extern int __hldtoa(long double d, const char *xdigs, int prec, char *cp,
++    int *expt, int *signflag, char **dtoaend);
++#endif /* !__TYPE_LONGDOUBLE_IS_DOUBLE */
++#endif /* HEXFLOAT */
++
+ /*
+  * The size of the buffer we use as scratch space for integer
+  * conversions, among other things.  Technically, we would need the
+@@ -452,6 +518,9 @@
  #define	PTRDIFFT	0x800		/* ptrdiff_t */
  #define	INTMAXT		0x1000		/* intmax_t */
  #define	CHARINT		0x2000		/* print char using int format */
@@ -193,15 +131,7 @@
  
  /*
   * Non-MT-safe version
-  */
--int
--__vfprintf(FILE *fp, const char *fmt0, va_list ap)
-+__private_extern__ int
-+__vfprintf(FILE *fp, locale_t loc, const char *fmt0, va_list ap)
- {
- 	char *fmt;		/* format string */
- 	int ch;			/* character from fmt */
-@@ -502,6 +575,11 @@
+@@ -503,6 +572,11 @@
  	int nseps;		/* number of group separators with ' */
  	int nrepeats;		/* number of repeats of the last group */
  #endif
@@ -213,7 +143,20 @@
  	u_long	ulval;		/* integer arguments %[diouxX] */
  	uintmax_t ujval;	/* %j, %ll, %q, %t, %z integers */
  	int base;		/* base for [diouxX] conversion */
-@@ -574,15 +652,6 @@
+@@ -535,6 +609,12 @@
+ 
+ 	static const char xdigs_lower[16] = "0123456789abcdef";
+ 	static const char xdigs_upper[16] = "0123456789ABCDEF";
++#ifdef HEXFLOAT
++#define HEXFLOATDELTA	32
++#define HEXFLOATSTART	32
++	static char *hexfloat = NULL;
++	static int hexfloatlen = 0;
++#endif /* HEXFLOAT */
+ 
+ 	/*
+ 	 * BEWARE, these `goto error' on error, and PAD uses `n'.
+@@ -575,15 +655,6 @@
  }
  
  	/*
@@ -229,7 +172,7 @@
  	 * To extend shorts properly, we need both signed and unsigned
  	 * argument extraction methods.
  	 */
-@@ -633,22 +702,23 @@
+@@ -634,7 +705,6 @@
  		val = GETARG (int); \
  	}
  
@@ -237,27 +180,19 @@
  	thousands_sep = '\0';
  	grouping = NULL;
  	convbuf = NULL;
- #ifndef NO_FLOATING_POINT
- 	dtoaresult = NULL;
--	decimal_point = localeconv()->decimal_point;
-+	decimal_point = localeconv_l(loc)->decimal_point;
+@@ -643,8 +713,10 @@
+ 	decimal_point = localeconv()->decimal_point;
  #endif
  	/* sorry, fprintf(read_only_file, "") returns EOF, not 0 */
--	if (prepwrite(fp) != 0)
-+	if (prepwrite(fp) != 0) {
+-	if (cantwrite(fp))
++	if (cantwrite(fp)) {
 +		errno = EBADF;
  		return (EOF);
 +	}
  
  	/* optimise fprintf(stderr) (and other unbuffered Unix files) */
  	if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) &&
- 	    fp->_file >= 0)
--		return (__sbprintf(fp, fmt0, ap));
-+		return (__sbprintf(fp, loc, fmt0, ap));
- 
- 	fmt = (char *)fmt0;
- 	argtable = NULL;
-@@ -675,6 +745,9 @@
+@@ -676,6 +748,9 @@
  		}
  		if (ch == '\0')
  			goto done;
@@ -267,7 +202,7 @@
  		fmt++;		/* skip over '%' */
  
  		flags = 0;
-@@ -683,6 +756,9 @@
+@@ -684,6 +759,9 @@
  		prec = -1;
  		sign = '\0';
  		ox[1] = '\0';
@@ -277,7 +212,7 @@
  
  rflag:		ch = *fmt++;
  reswitch:	switch (ch) {
-@@ -698,6 +774,11 @@
+@@ -699,6 +777,11 @@
  		case '#':
  			flags |= ALT;
  			goto rflag;
@@ -289,41 +224,20 @@
  		case '*':
  			/*-
  			 * ``A negative field width argument is taken as a
-@@ -718,8 +799,8 @@
- 			goto rflag;
- 		case '\'':
- 			flags |= GROUPING;
--			thousands_sep = *(localeconv()->thousands_sep);
--			grouping = localeconv()->grouping;
-+			thousands_sep = *(localeconv_l(loc)->thousands_sep);
-+			grouping = localeconv_l(loc)->grouping;
- 			goto rflag;
- 		case '.':
- 			if ((ch = *fmt++) == '*') {
-@@ -793,14 +874,20 @@
- 			flags |= LONGINT;
- 			/*FALLTHROUGH*/
- 		case 'c':
-+#ifdef ALTIVEC
-+			if (flags & VECTOR) {
-+				SETVEC(vval);
-+				break;
-+			}
-+#endif /* ALTIVEC */
- 			if (flags & LONGINT) {
- 				static const mbstate_t initial;
- 				mbstate_t mbs;
- 				size_t mbseqlen;
- 
- 				mbs = initial;
--				mbseqlen = wcrtomb(cp = buf,
--				    (wchar_t)GETARG(wint_t), &mbs);
-+				mbseqlen = wcrtomb_l(cp = buf,
-+				    (wchar_t)GETARG(wint_t), &mbs, loc);
- 				if (mbseqlen == (size_t)-1) {
- 					fp->_flags |= __SERR;
- 					goto error;
-@@ -817,6 +904,12 @@
+@@ -807,6 +890,12 @@
+ 				}
+ 				size = (int)mbseqlen;
+ 			} else {
++#ifdef ALTIVEC
++				if (flags & VECTOR) {
++					SETVEC(vval);
++					break;
++				}
++#endif /* ALTIVEC */
+ 				*(cp = buf) = GETARG(int);
+ 				size = 1;
+ 			}
+@@ -817,6 +906,12 @@
  			/*FALLTHROUGH*/
  		case 'd':
  		case 'i':
@@ -331,13 +245,13 @@
 +			if (flags & VECTOR) {
 +				SETVEC(vval);
 +				break;
-+			}
++			} else
 +#endif /* ALTIVEC */
  			if (flags & INTMAX_SIZE) {
  				ujval = SJARG();
  				if ((intmax_t)ujval < 0) {
-@@ -835,6 +928,13 @@
- #ifndef NO_FLOATING_POINT
+@@ -836,6 +931,13 @@
+ #ifdef HEXFLOAT
  		case 'a':
  		case 'A':
 +#ifdef ALTIVEC
@@ -350,29 +264,56 @@
  			if (ch == 'a') {
  				ox[1] = 'x';
  				xdigs = xdigs_lower;
-@@ -848,6 +948,12 @@
- 				prec++;
- 			if (dtoaresult != NULL)
- 				freedtoa(dtoaresult);
-+#ifdef LDBL_COMPAT
-+			fparg.dbl = GETARG(double);
-+			dtoaresult = cp =
-+			    __hdtoa(fparg.dbl, xdigs, prec,
-+			    &expt, &signflag, &dtoaend);
-+#else /* !LDBL_COMPAT */
+@@ -845,25 +947,51 @@
+ 				xdigs = xdigs_upper;
+ 				expchar = 'P';
+ 			}
+-			/*
+-			 * XXX We don't actually have a conversion
+-			 * XXX routine for this yet.
+-			 */
++			if (!hexfloat) {
++				hexfloat = malloc(hexfloatlen = HEXFLOATSTART);
++				if (!hexfloat)
++					goto error;
++			}
++			if (prec > hexfloatlen - 1) {
++				int hlen = prec + HEXFLOATDELTA;
++				char *hf = realloc(hexfloat, hlen);
++				if (hf == NULL)
++					goto error;
++				hexfloat = hf;
++				hexfloatlen = hlen;
++			}
++			cp = hexfloat;
  			if (flags & LONGDBL) {
- 				fparg.ldbl = GETARG(long double);
- 				dtoaresult = cp =
-@@ -859,6 +965,7 @@
- 				    __hdtoa(fparg.dbl, xdigs, prec,
+-				fparg.ldbl = (double)GETARG(long double);
+-				dtoaresult = cp =
+-				    __hldtoa(fparg.ldbl, xdigs, prec,
++#if __TYPE_LONGDOUBLE_IS_DOUBLE
++				fparg.dbl = (double)GETARG(long double);
++				prec = __hdtoa(fparg.dbl, xdigs, prec, cp,
+ 				    &expt, &signflag, &dtoaend);
++#else /* ! __TYPE_LONGDOUBLE_IS_DOUBLE */
++				fparg.ldbl = GETARG(long double);
++				prec = __hldtoa(fparg.ldbl, xdigs, prec, cp,
++				    &expt, &signflag, &dtoaend);
++#endif /* __TYPE_LONGDOUBLE_IS_DOUBLE */
+ 			} else {
+ 				fparg.dbl = GETARG(double);
+-				dtoaresult = cp =
+-				    __hdtoa(fparg.dbl, xdigs, prec,
++				prec = __hdtoa(fparg.dbl, xdigs, prec, cp,
  				    &expt, &signflag, &dtoaend);
  			}
-+#endif /* LDBL_COMPAT */
- 			if (prec < 0)
- 				prec = dtoaend - cp;
- 			if (expt == INT_MAX)
-@@ -866,6 +973,13 @@
- 			goto fp_common;
+-			goto fp_begin;
++			prec++;
++			if (expt == INT_MAX)
++				ox[1] = 0;
++			else
++				expt++;
++			goto hex_begin;
+ #endif
  		case 'e':
  		case 'E':
 +#ifdef ALTIVEC
@@ -385,7 +326,7 @@
  			expchar = ch;
  			if (prec < 0)	/* account for digit before decpt */
  				prec = DEFPREC + 1;
-@@ -874,10 +988,24 @@
+@@ -872,10 +1000,24 @@
  			goto fp_begin;
  		case 'f':
  		case 'F':
@@ -410,30 +351,36 @@
  			expchar = ch - ('g' - 'e');
  			if (prec == 0)
  				prec = 1;
-@@ -886,6 +1014,14 @@
+@@ -884,6 +1026,17 @@
  				prec = DEFPREC;
  			if (dtoaresult != NULL)
  				freedtoa(dtoaresult);
-+#ifdef LDBL_COMPAT
-+			fparg.dbl = GETARG(double);
++#if __TYPE_LONGDOUBLE_IS_DOUBLE
++			if (flags & LONGDBL)
++				fparg.dbl = (double)GETARG(long double);
++			else
++				fparg.dbl = GETARG(double);
 +			dtoaresult = cp =
 +			    dtoa(fparg.dbl, expchar ? 2 : 3, prec,
 +			    &expt, &signflag, &dtoaend);
 +			if (expt == 9999)
 +				expt = INT_MAX;
-+#else /* !LDBL_COMPAT */
++#else /* ! __TYPE_LONGDOUBLE_IS_DOUBLE */
  			if (flags & LONGDBL) {
  				fparg.ldbl = GETARG(long double);
  				dtoaresult = cp =
-@@ -899,6 +1035,7 @@
+@@ -897,6 +1050,10 @@
  				if (expt == 9999)
  					expt = INT_MAX;
  			}
-+#endif /* LDBL_COMPAT */
- fp_common:
++#endif /* __TYPE_LONGDOUBLE_IS_DOUBLE */
++#ifdef HEXFLOAT
++hex_begin:
++#endif /* HEXFLOAT */
  			if (signflag)
  				sign = '-';
-@@ -993,6 +1130,12 @@
+ 			if (expt == INT_MAX) {	/* inf or nan */
+@@ -990,6 +1147,12 @@
  			flags |= LONGINT;
  			/*FALLTHROUGH*/
  		case 'o':
@@ -441,12 +388,12 @@
 +			if (flags & VECTOR) {
 +				SETVEC(vval);
 +				break;
-+			}
++			} else
 +#endif /* ALTIVEC */
  			if (flags & INTMAX_SIZE)
  				ujval = UJARG();
  			else
-@@ -1007,6 +1150,12 @@
+@@ -1004,6 +1167,12 @@
  			 * defined manner.''
  			 *	-- ANSI X3J11
  			 */
@@ -459,16 +406,7 @@
  			ujval = (uintmax_t)(uintptr_t)GETARG(void *);
  			base = 16;
  			xdigs = xdigs_lower;
-@@ -1025,7 +1174,7 @@
- 				if ((wcp = GETARG(wchar_t *)) == NULL)
- 					cp = "(null)";
- 				else {
--					convbuf = __wcsconv(wcp, prec);
-+					convbuf = __wcsconv(wcp, prec, loc);
- 					if (convbuf == NULL) {
- 						fp->_flags |= __SERR;
- 						goto error;
-@@ -1056,6 +1205,12 @@
+@@ -1053,6 +1222,12 @@
  			flags |= LONGINT;
  			/*FALLTHROUGH*/
  		case 'u':
@@ -476,12 +414,12 @@
 +			if (flags & VECTOR) {
 +				SETVEC(vval);
 +				break;
-+			}
++			} else
 +#endif /* ALTIVEC */
  			if (flags & INTMAX_SIZE)
  				ujval = UJARG();
  			else
-@@ -1068,6 +1223,12 @@
+@@ -1065,6 +1240,12 @@
  		case 'x':
  			xdigs = xdigs_lower;
  hex:
@@ -489,12 +427,12 @@
 +			if (flags & VECTOR) {
 +				SETVEC(vval);
 +				break;
-+			}
++			} else
 +#endif /* ALTIVEC */
  			if (flags & INTMAX_SIZE)
  				ujval = UJARG();
  			else
-@@ -1112,6 +1273,14 @@
+@@ -1109,6 +1290,14 @@
  			if (size > BUF)	/* should never happen */
  				abort();
  			break;
@@ -509,7 +447,7 @@
  		default:	/* "%?" prints ?, unless ? is NUL */
  			if (ch == '\0')
  				goto done;
-@@ -1123,6 +1292,184 @@
+@@ -1120,6 +1309,186 @@
  			break;
  		}
  
@@ -573,12 +511,10 @@
 +			 * finish up the format specifier.
 +			 */
 +			if (flags & SHORTINT) {
-+				if (ch != 'c')
-+					vfmt[j++] = 'h';
++				vfmt[j++] = 'h';
 +				vcnt = 8;
 +			} else if (flags & LONGINT) {
-+				if (ch != 'c')
-+					vfmt[j++] = 'l';
++				vfmt[j++] = 'l';
 +				vcnt = 4;
 +			} else {
 +				switch (ch) {
@@ -614,7 +550,7 @@
 +#define VPRINT(cnt, ind, args...) do {					\
 +	if (flags & FPT) {						\
 +		velm.f = vval.vfloatarg[ind];				\
-+		vlen = asprintf_l(&vstr, loc, vfmt , ## args, velm.f);	\
++		vlen = asprintf(&vstr, vfmt , ## args, velm.f);		\
 +	} else {							\
 +		switch (cnt) {						\
 +		default:						\
@@ -629,7 +565,7 @@
 +			velm.i = (unsigned char)vval.vchararg[ind];	\
 +			break;						\
 +		}							\
-+		vlen = asprintf_l(&vstr, loc, vfmt , ## args, velm.i);	\
++		vlen = asprintf(&vstr, vfmt , ## args, velm.i);		\
 +	}								\
 +	ret += vlen;							\
 +	PRINT(vstr, vlen);						\
@@ -644,7 +580,8 @@
 +					VPRINT(vcnt, 0);
 +					for (i = 1; i < vcnt; i++) {
 +						/* Separator. */
-+						PRINT(&vsep, 1);
++						if (vsep)
++							PRINT(&vsep, 1);
 +
 +						/* Element. */
 +						VPRINT(vcnt, i);
@@ -654,7 +591,8 @@
 +					VPRINT(vcnt, 0, prec);
 +					for (i = 1; i < vcnt; i++) {
 +						/* Separator. */
-+						PRINT(&vsep, 1);
++						if (vsep)
++							PRINT(&vsep, 1);
 +
 +						/* Element. */
 +						VPRINT(vcnt, i, prec);
@@ -666,7 +604,8 @@
 +					VPRINT(vcnt, 0, width);
 +					for (i = 1; i < vcnt; i++) {
 +						/* Separator. */
-+						PRINT(&vsep, 1);
++						if (vsep)
++							PRINT(&vsep, 1);
 +
 +						/* Element. */
 +						VPRINT(vcnt, i, width);
@@ -676,7 +615,8 @@
 +					VPRINT(vcnt, 0, width, prec);
 +					for (i = 1; i < vcnt; i++) {
 +						/* Separator. */
-+						PRINT(&vsep, 1);
++						if (vsep)
++							PRINT(&vsep, 1);
 +
 +						/* Element. */
 +						VPRINT(vcnt, i, width, prec);
@@ -694,7 +634,28 @@
  		/*
  		 * All reasonable formats wind up here.  At this point, `cp'
  		 * points to a string which (if not flags&LADJUST) should be
-@@ -1406,6 +1753,11 @@
+@@ -1137,7 +1506,7 @@
+ 		realsz = dprec > size ? dprec : size;
+ 		if (sign)
+ 			realsz++;
+-		else if (ox[1])
++		if (ox[1])
+ 			realsz += 2;
+ 
+ 		prsize = width > realsz ? width : realsz;
+@@ -1151,9 +1520,9 @@
+ 			PAD(width - realsz, blanks);
+ 
+ 		/* prefix */
+-		if (sign) {
++		if (sign)
+ 			PRINT(&sign, 1);
+-		} else if (ox[1]) {	/* ox[1] is either x, X, or \0 */
++		if (ox[1]) {	/* ox[1] is either x, X, or \0 */
+ 			ox[0] = '0';
+ 			PRINT(ox, 2);
+ 		}
+@@ -1400,6 +1769,11 @@
  			if (flags & LONGINT)
  				ADDTYPE(T_WINT);
  			else
@@ -706,7 +667,7 @@
  				ADDTYPE(T_INT);
  			break;
  		case 'D':
-@@ -1413,6 +1765,11 @@
+@@ -1407,6 +1781,11 @@
  			/*FALLTHROUGH*/
  		case 'd':
  		case 'i':
@@ -717,8 +678,8 @@
 +#endif
  			ADDSARG();
  			break;
- #ifndef NO_FLOATING_POINT
-@@ -1423,6 +1780,11 @@
+ #ifdef FLOATING_POINT
+@@ -1419,6 +1798,11 @@
  		case 'f':
  		case 'g':
  		case 'G':
@@ -730,7 +691,7 @@
  			if (flags & LONGDBL)
  				ADDTYPE(T_LONG_DOUBLE);
  			else
-@@ -1451,9 +1813,19 @@
+@@ -1447,9 +1831,19 @@
  			flags |= LONGINT;
  			/*FALLTHROUGH*/
  		case 'o':
@@ -750,7 +711,7 @@
  			ADDTYPE(TP_VOID);
  			break;
  		case 'S':
-@@ -1471,6 +1843,11 @@
+@@ -1467,6 +1861,11 @@
  		case 'u':
  		case 'X':
  		case 'x':
@@ -762,16 +723,7 @@
  			ADDUARG();
  			break;
  		default:	/* "%?" prints ?, unless ? is NUL */
-@@ -1537,7 +1914,7 @@
- 			(*argtable) [n].sizearg = va_arg (ap, size_t);
- 			break;
- 		    case TP_SIZET:
--			(*argtable) [n].psizearg = va_arg (ap, ssize_t *);
-+			(*argtable) [n].psizearg = va_arg (ap, size_t *);
- 			break;
- 		    case T_INTMAXT:
- 			(*argtable) [n].intmaxarg = va_arg (ap, intmax_t);
-@@ -1556,6 +1933,12 @@
+@@ -1552,6 +1951,12 @@
  			(*argtable) [n].longdoublearg = va_arg (ap, long double);
  			break;
  #endif