OSDN Git Service

Implement all needed hidden *printf and correct vasprintf, thx blindvt
authorPeter S. Mazinger <ps.m@gmx.net>
Fri, 9 Dec 2005 13:52:08 +0000 (13:52 -0000)
committerPeter S. Mazinger <ps.m@gmx.net>
Fri, 9 Dec 2005 13:52:08 +0000 (13:52 -0000)
15 files changed:
libc/stdio/_stdio.h
libc/stdio/fprintf.c
libc/stdio/old_vfprintf.c
libc/stdio/printf.c
libc/stdio/snprintf.c
libc/stdio/sprintf.c
libc/stdio/vasprintf.c
libc/stdio/vdprintf.c
libc/stdio/vfprintf.c
libc/stdio/vprintf.c
libc/stdio/vsnprintf.c
libc/stdio/vsprintf.c
libc/stdio/vswprintf.c
libc/stdio/vwprintf.c
libc/stdio/wprintf.c

index e4aa5d7..7dd105c 100644 (file)
 #include <string.h>
 #include <unistd.h>
 
+extern int __vfprintf (FILE *__restrict __s, __const char *__restrict __format,
+                    __gnuc_va_list __arg) attribute_hidden;
+
+extern int __vsnprintf (char *__restrict __s, size_t __maxlen,
+                     __const char *__restrict __format, __gnuc_va_list __arg)
+     __THROW __attribute__ ((__format__ (__printf__, 3, 0))) attribute_hidden;
+
+extern int __vfwprintf (__FILE *__restrict __s,
+                     __const wchar_t *__restrict __format,
+                     __gnuc_va_list __arg) attribute_hidden;
+
 #ifdef __UCLIBC_HAS_WCHAR__
 #include <wchar.h>
 #endif
index 388eb0c..07769bb 100644 (file)
@@ -8,14 +8,15 @@
 #include "_stdio.h"
 #include <stdarg.h>
 
-int fprintf(FILE * __restrict stream, const char * __restrict format, ...)
+int attribute_hidden __fprintf(FILE * __restrict stream, const char * __restrict format, ...)
 {
        va_list arg;
        int rv;
 
        va_start(arg, format);
-       rv = vfprintf(stream, format, arg);
+       rv = __vfprintf(stream, format, arg);
        va_end(arg);
 
        return rv;
 }
+strong_alias(__fprintf,fprintf)
index a9e4528..8b54ca8 100644 (file)
@@ -341,7 +341,7 @@ static const char u_spec[] = "%nbopxXudics";
 /* u_radix[i] <-> u_spec[i+2] for unsigned entries only */
 static const char u_radix[] = "\x02\x08\x10\x10\x10\x0a";
 
-int vfprintf(FILE * __restrict op, register const char * __restrict fmt,
+int attribute_hidden __vfprintf(FILE * __restrict op, register const char * __restrict fmt,
                         va_list ap)
 {
        union {
@@ -711,3 +711,4 @@ int vfprintf(FILE * __restrict op, register const char * __restrict fmt,
 
        return i;
 }
+strong_alias(__vfprintf,vfprintf)
index 67db4b3..82326a9 100644 (file)
@@ -8,14 +8,15 @@
 #include "_stdio.h"
 #include <stdarg.h>
 
-int printf(const char * __restrict format, ...)
+int attribute_hidden __printf(const char * __restrict format, ...)
 {
        va_list arg;
        int rv;
 
        va_start(arg, format);
-       rv = vfprintf(stdout, format, arg);
+       rv = __vfprintf(stdout, format, arg);
        va_end(arg);
 
        return rv;
 }
+strong_alias(__printf,printf)
index a827971..a1ea79f 100644 (file)
 #warning Skipping snprintf since no vsnprintf!
 #else
 
-int snprintf(char *__restrict buf, size_t size,
+int attribute_hidden __snprintf(char *__restrict buf, size_t size,
                         const char * __restrict format, ...)
 {
        va_list arg;
        int rv;
 
        va_start(arg, format);
-       rv = vsnprintf(buf, size, format, arg);
+       rv = __vsnprintf(buf, size, format, arg);
        va_end(arg);
        return rv;
 }
+strong_alias(__snprintf,snprintf)
 
 #endif
index eb83f42..5778c01 100644 (file)
 #warning Skipping sprintf since no vsnprintf!
 #else
 
-int sprintf(char *__restrict buf, const char * __restrict format, ...)
+int attribute_hidden __sprintf(char *__restrict buf, const char * __restrict format, ...)
 {
        va_list arg;
        int rv;
 
        va_start(arg, format);
-       rv = vsnprintf(buf, SIZE_MAX, format, arg);
+       rv = __vsnprintf(buf, SIZE_MAX, format, arg);
        va_end(arg);
 
        return rv;
 }
+strong_alias(__sprintf,sprintf)
 
 #endif
index 8aa2c9a..ca110cb 100644 (file)
@@ -32,7 +32,7 @@ int attribute_hidden __vasprintf(char **__restrict buf, const char * __restrict
        *buf = NULL;
 
        if ((f = open_memstream(buf, &size)) != NULL) {
-               rv = vfprintf(f, format, arg);
+               rv = __vfprintf(f, format, arg);
                fclose(f);
                if (rv < 0) {
                        free(*buf);
@@ -54,14 +54,14 @@ int attribute_hidden __vasprintf(char **__restrict buf, const char * __restrict
        int rv;
 
        va_copy(arg2, arg);
-       rv = vsnprintf(NULL, 0, format, arg2);
+       rv = __vsnprintf(NULL, 0, format, arg2);
        va_end(arg2);
 
        *buf = NULL;
 
        if (rv >= 0) {
                if ((*buf = malloc(++rv)) != NULL) {
-                       if ((rv = vsnprintf(*buf, rv, format, arg)) < 0) {
+                       if ((rv = __vsnprintf(*buf, rv, format, arg)) < 0) {
                                free(*buf);
                                *buf = NULL;
                        }
@@ -73,7 +73,7 @@ int attribute_hidden __vasprintf(char **__restrict buf, const char * __restrict
        return rv;
 
 #endif /* __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ */
-strong_alias(__vasprintf,vasprintf)
 }
+strong_alias(__vasprintf,vasprintf)
 
 #endif
index 5628738..1822f69 100644 (file)
@@ -47,7 +47,7 @@ int attribute_hidden __vdprintf(int filedes, const char * __restrict format, va_
 #endif
        f.__nextopen = NULL;
 
-       rv = vfprintf(&f, format, arg);
+       rv = __vfprintf(&f, format, arg);
 
 #ifdef __STDIO_BUFFERS
        /* If not buffering, then fflush is unnecessary. */
index 793b991..11fe926 100644 (file)
@@ -1195,6 +1195,7 @@ static size_t _charpad(FILE * __restrict stream, int padchar, size_t numpad);
 
 #ifdef L_vfprintf
 
+#define HIDDEN_VFPRINTF __vfprintf
 #define VFPRINTF vfprintf
 #define FMT_TYPE char
 #define OUTNSTR _outnstr
@@ -1227,6 +1228,7 @@ static size_t _fp_out_narrow(FILE *fp, intptr_t type, intptr_t len, intptr_t buf
 
 #else  /* L_vfprintf */
 
+#define HIDDEN_VFPRINTF __vfwprintf
 #define VFPRINTF vfwprintf
 #define FMT_TYPE wchar_t
 #define OUTNSTR _outnwcs
@@ -1844,7 +1846,7 @@ static int _do_one_spec(FILE * __restrict stream,
        return 0;
 }
 
-int VFPRINTF (FILE * __restrict stream,
+int attribute_hidden HIDDEN_VFPRINTF (FILE * __restrict stream,
                          register const FMT_TYPE * __restrict format,
                          va_list arg)
 {
@@ -1921,5 +1923,6 @@ int VFPRINTF (FILE * __restrict stream,
 
        return count;
 }
+strong_alias(HIDDEN_VFPRINTF,VFPRINTF)
 #endif
 /**********************************************************************/
index 45d580f..9c0e075 100644 (file)
@@ -10,5 +10,5 @@
 
 int vprintf(const char * __restrict format, va_list arg)
 {
-       return vfprintf(stdout, format, arg);
+       return __vfprintf(stdout, format, arg);
 }
index ffe33ad..6fcc84f 100644 (file)
@@ -14,7 +14,7 @@
 
 #ifdef __STDIO_BUFFERS
 
-int vsnprintf(char *__restrict buf, size_t size,
+int attribute_hidden __vsnprintf(char *__restrict buf, size_t size,
                          const char * __restrict format, va_list arg)
 {
        FILE f;
@@ -57,7 +57,7 @@ int vsnprintf(char *__restrict buf, size_t size,
        __STDIO_STREAM_DISABLE_GETC(&f);
        __STDIO_STREAM_ENABLE_PUTC(&f);
 
-       rv = vfprintf(&f, format, arg);
+       rv = __vfprintf(&f, format, arg);
        if (size) {
                if (f.__bufpos == f.__bufend) {
                        --f.__bufpos;
@@ -66,6 +66,7 @@ int vsnprintf(char *__restrict buf, size_t size,
        }
        return rv;
 }
+strong_alias(__vsnprintf,vsnprintf)
 
 #elif defined(__USE_OLD_VFPRINTF__)
 
@@ -75,7 +76,7 @@ typedef struct {
        unsigned char *bufpos;
 } __FILE_vsnprintf;
 
-int vsnprintf(char *__restrict buf, size_t size,
+int attribute_hidden __vsnprintf(char *__restrict buf, size_t size,
                          const char * __restrict format, va_list arg)
 {
        __FILE_vsnprintf f;
@@ -113,7 +114,7 @@ int vsnprintf(char *__restrict buf, size_t size,
 #endif
        f.f.__nextopen = NULL;
 
-       rv = vfprintf((FILE *) &f, format, arg);
+       rv = __vfprintf((FILE *) &f, format, arg);
        if (size) {
                if (f.bufpos == f.bufend) {
                        --f.bufpos;
@@ -122,6 +123,7 @@ int vsnprintf(char *__restrict buf, size_t size,
        }
        return rv;
 }
+strong_alias(__vsnprintf,vsnprintf)
 
 #elif defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__)
 
@@ -163,7 +165,7 @@ static ssize_t snpf_write(register void *cookie, const char *buf,
 
 #undef COOKIE
 
-int vsnprintf(char *__restrict buf, size_t size,
+int attribute_hidden __vsnprintf(char *__restrict buf, size_t size,
                          const char * __restrict format, va_list arg)
 {
        FILE f;
@@ -197,10 +199,11 @@ int vsnprintf(char *__restrict buf, size_t size,
 #endif
        f.__nextopen = NULL;
 
-       rv = vfprintf(&f, format, arg);
+       rv = __vfprintf(&f, format, arg);
 
        return rv;
 }
+strong_alias(__vsnprintf,vsnprintf)
 
 #else
 #warning Skipping vsnprintf since no buffering, no custom streams, and not old vfprintf!
index 81d3961..a7d5e08 100644 (file)
@@ -15,7 +15,7 @@
 int vsprintf(char *__restrict buf, const char * __restrict format,
                         va_list arg)
 {
-       return vsnprintf(buf, SIZE_MAX, format, arg);
+       return __vsnprintf(buf, SIZE_MAX, format, arg);
 }
 
 #endif
index d7dca5e..d23ba12 100644 (file)
@@ -52,7 +52,7 @@ int attribute_hidden __vswprintf(wchar_t *__restrict buf, size_t size,
        __STDIO_STREAM_DISABLE_GETC(&f);
        __STDIO_STREAM_DISABLE_PUTC(&f);
 
-       rv = vfwprintf(&f, format, arg);
+       rv = __vfwprintf(&f, format, arg);
 
        /* NOTE: Return behaviour differs from snprintf... */
        if (f.__bufpos == f.__bufend) {
index 2ad6bbd..8c34018 100644 (file)
@@ -11,5 +11,5 @@
 
 int vwprintf(const wchar_t * __restrict format, va_list arg)
 {
-       return vfwprintf(stdout, format, arg);
+       return __vfwprintf(stdout, format, arg);
 }
index c64fc08..00f5ef5 100644 (file)
@@ -15,7 +15,7 @@ int wprintf(const wchar_t * __restrict format, ...)
        int rv;
 
        va_start(arg, format);
-       rv = vfwprintf(stdout, format, arg);
+       rv = __vfwprintf(stdout, format, arg);
        va_end(arg);
 
        return rv;