Loading...
--- Libc/Libc-1725.40.4/stdio/FreeBSD/vfwprintf.c
+++ Libc/Libc-1158.1.2/stdio/FreeBSD/vfwprintf.c
@@ -64,9 +64,6 @@
#include <errno.h>
#include "un-namespace.h"
-#include <os/assumes.h>
-#include <mach-o/dyld_priv.h>
-
#include "libc_private.h"
#include "local.h"
#include "fvwrite.h"
@@ -376,9 +373,6 @@
return vfwprintf_l(fp, __current_locale(), fmt0, ap);
}
-// Defined in vfprintf.c
-bool __printf_is_memory_read_only(void *addr, size_t size);
-
/*
* The size of the buffer we use as scratch space for integer
* conversions, among other things. We need enough space to
@@ -398,15 +392,14 @@
{
wchar_t *fmt; /* format string */
wchar_t ch; /* character from fmt */
- ssize_t n, n2; /* handy integer (short term usage) */
+ int n, n2; /* handy integer (short term usage) */
wchar_t *cp; /* handy char pointer (short term usage) */
int flags; /* flags as above */
- ssize_t ret; /* return value accumulator */
- ssize_t width; /* width from format (%8d), or 0 */
- ssize_t prec; /* precision from format; <0 for N/A */
+ int ret; /* return value accumulator */
+ int width; /* width from format (%8d), or 0 */
+ int prec; /* precision from format; <0 for N/A */
wchar_t sign; /* sign prefix (' ', '+', '-', or \0) */
struct grouping_state gs; /* thousands' grouping info */
-
#ifndef NO_FLOATING_POINT
/*
* We can decompose the printed representation of floating
@@ -445,9 +438,9 @@
uintmax_t ujval; /* %j, %ll, %q, %t, %z integers */
int base; /* base for [diouxX] conversion */
int dprec; /* a copy of prec if [diouxX], 0 otherwise */
- ssize_t realsz; /* field size expanded by dprec, sign, etc */
- ssize_t size; /* size of converted field or string */
- ssize_t prsize; /* max size of printed field */
+ int realsz; /* field size expanded by dprec, sign, etc */
+ int size; /* size of converted field or string */
+ int prsize; /* max size of printed field */
const char *xdigs; /* digits for [xX] conversion */
struct io_state io; /* I/O buffering state */
wchar_t buf[BUF]; /* buffer with space for digits of uintmax_t */
@@ -568,9 +561,8 @@
for (cp = fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++)
/* void */;
if ((n = fmt - cp) != 0) {
- if (ret + n > INT_MAX) {
+ if ((unsigned)ret + n > INT_MAX) {
ret = EOF;
- errno = EOVERFLOW;
goto error;
}
PRINT(cp, n);
@@ -901,8 +893,7 @@
void *ptr = GETARG(void *);
if (ptr == NULL)
continue;
-
- if (flags & LLONGINT)
+ else if (flags & LLONGINT)
*(long long *)ptr = ret;
else if (flags & SIZET)
*(ssize_t *)ptr = (ssize_t)ret;
@@ -979,11 +970,6 @@
size = (prec >= 0) ? wcsnlen(cp, prec) : wcslen(cp);
#else
size = wcslen(cp);
- if (size >= INT_MAX) {
- ret = EOF;
- errno = EOVERFLOW;
- goto error;
- }
if(prec >= 0 && prec < size)
size = prec;
#endif
@@ -1058,7 +1044,7 @@
}
size = buf + BUF - cp;
if (size > BUF) /* should never happen */
- LIBC_ABORT("size (%zd) > BUF (%d)", size, BUF);
+ LIBC_ABORT("size (%d) > BUF (%d)", size, BUF);
if ((flags & GROUPING) && size != 0)
size += grouping_init(&gs, size, loc);
break;
@@ -1381,9 +1367,8 @@
realsz += 2;
prsize = width > realsz ? width : realsz;
- if (ret + prsize > INT_MAX) {
+ if ((unsigned)ret + prsize > INT_MAX) {
ret = EOF;
- errno = EOVERFLOW;
goto error;
}
@@ -1473,6 +1458,6 @@
ret = EOF;
if ((argtable != NULL) && (argtable != statargtable))
free (argtable);
- return (ret < 0 || ret >= INT_MAX) ? -1 : (int)ret;
+ return (ret);
/* NOTREACHED */
}