diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-01-11 11:42:17 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-01-11 11:42:17 +0000 |
commit | ae97a89e1a1a9833080dccc81f6cd26784e1b964 (patch) | |
tree | 6ff1ddc7e3980591c7fd0bbd5d9b8ac82da12886 /libc/stdio/printf.c | |
parent | abdc3e4d06db2b9d93c509774fc7c4fde918ec8e (diff) |
A large update from Manuel Novoa III <mnovoa3@bellsouth.net>.
Diffstat (limited to 'libc/stdio/printf.c')
-rw-r--r-- | libc/stdio/printf.c | 66 |
1 files changed, 30 insertions, 36 deletions
diff --git a/libc/stdio/printf.c b/libc/stdio/printf.c index 634885e67..ffca106e4 100644 --- a/libc/stdio/printf.c +++ b/libc/stdio/printf.c @@ -8,7 +8,7 @@ * "It's not reality that's important, but how you perceive things." */ -/* Altered to use stdarg, made the core function vfprintf. +/* Altered to use stdarg, made the core function vfnprintf. * Hooked into the stdio package using 'inside information' * Altered sizeof() assumptions, now assumes all integers except chars * will be either @@ -20,7 +20,7 @@ /* * Manuel Novoa III Dec 2000 * - * The previous vfprintf routine was almost completely rewritten with the + * The previous vfnprintf routine was almost completely rewritten with the * goal of fixing some shortcomings and reducing object size. * * The summary of changes: @@ -52,6 +52,8 @@ * Converted to use my (un)signed long (long) to string routines, which are * smaller than the previous functions and don't require static buffers. * + * Other Modifications: + * Modified sprintf, snprintf, vsprintf, vsnprintf to share on fake-file. */ /*****************************************************************************/ @@ -122,6 +124,14 @@ extern int vfnprintf(FILE * op, size_t max_size, register __const char *fmt, register va_list ap); +extern FILE __sprintf_fake_file[1]; + +#ifdef L__sprintf_fake_file +FILE __sprintf_fake_file[1] = { + {0, 0, (char *) (unsigned) -1, 0, (char *) (unsigned) -1, -1, + _IOFBF | __MODE_WRITE} +}; +#endif #ifdef L_printf int printf(const char *fmt, ...) @@ -139,19 +149,14 @@ int printf(const char *fmt, ...) #ifdef L_sprintf int sprintf(char *sp, const char *fmt, ...) { - static FILE string[1] = { - {0, 0, (char *) (unsigned) -1, 0, (char *) (unsigned) -1, -1, - _IOFBF | __MODE_WRITE} - }; - va_list ptr; int rv; va_strt(ptr, fmt); - string->bufpos = sp; - rv = vfnprintf(string, -1, fmt, ptr); + __sprintf_fake_file->bufpos = sp; + rv = vfnprintf(__sprintf_fake_file, -1, fmt, ptr); va_end(ptr); - *(string->bufpos) = 0; + *(__sprintf_fake_file->bufpos) = 0; return rv; } #endif @@ -160,19 +165,14 @@ int sprintf(char *sp, const char *fmt, ...) #ifdef L_snprintf int snprintf(char *sp, size_t size, const char *fmt, ...) { - static FILE string[1] = { - {0, 0, (char *) (unsigned) -1, 0, (char *) (unsigned) -1, -1, - _IOFBF | __MODE_WRITE} - }; - va_list ptr; int rv; va_strt(ptr, fmt); - string->bufpos = sp; - rv = vfnprintf(string, size, fmt, ptr); + __sprintf_fake_file->bufpos = sp; + rv = vfnprintf(__sprintf_fake_file, size, fmt, ptr); va_end(ptr); - *(string->bufpos) = 0; + *(__sprintf_fake_file->bufpos) = 0; return rv; } #endif @@ -200,38 +200,28 @@ int vprintf(const char *fmt, va_list ap) #ifdef L_vsprintf int vsprintf(char *sp, __const char *fmt, va_list ap) { - static FILE string[1] = { - {0, 0, (char *) (unsigned) -1, 0, (char *) (unsigned) -1, -1, - _IOFBF | __MODE_WRITE} - }; - int rv; - string->bufpos = sp; - rv = vfnprintf(string, -1, fmt, ap); - *(string->bufpos) = 0; + __sprintf_fake_file->bufpos = sp; + rv = vfnprintf(__sprintf_fake_file, -1, fmt, ap); + *(__sprintf_fake_file->bufpos) = 0; return rv; } #endif -#ifdef L_vsprintf +#ifdef L_vsnprintf int vsnprintf(char *sp, size_t size, __const char *fmt, va_list ap) { - static FILE string[1] = { - {0, 0, (char *) (unsigned) -1, 0, (char *) (unsigned) -1, -1, - _IOFBF | __MODE_WRITE} - }; - int rv; - string->bufpos = sp; - rv = vfnprintf(string, size, fmt, ap); - *(string->bufpos) = 0; + __sprintf_fake_file->bufpos = sp; + rv = vfnprintf(__sprintf_fake_file, size, fmt, ap); + *(__sprintf_fake_file->bufpos) = 0; return rv; } #endif -#ifdef L_vfprintf +#ifdef L_vfnprintf extern char *__ultostr(char *buf, unsigned long uval, int base, int uppercase); extern char *__ltostr(char *buf, long val, int base, int uppercase); @@ -591,6 +581,10 @@ int vfnprintf(FILE * op, size_t max_size, const char *fmt, va_list ap) return (cnt); } +#endif + +#ifdef L_vfprintf + int vfprintf(FILE * op, register __const char *fmt, register va_list ap) { return (vfnprintf(op, -1, fmt, ap)); |