summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter S. Mazinger <ps.m@gmx.net>2005-12-09 15:33:37 +0000
committerPeter S. Mazinger <ps.m@gmx.net>2005-12-09 15:33:37 +0000
commit06f8a796e2d4d88cfd89b21a2b7b195c3612ba81 (patch)
tree5a5494b08edc34fc3a88ebb4769403d89df7f752
parent60acdef20530daeaa65cbce8bb2a14c22bc0ed00 (diff)
Implement hidden *scanf
-rw-r--r--libc/stdio/_fpmaxtostr.c12
-rw-r--r--libc/stdio/_stdio.h15
-rw-r--r--libc/stdio/fprintf.c1
-rw-r--r--libc/stdio/fwprintf.c2
-rw-r--r--libc/stdio/scanf.c50
5 files changed, 53 insertions, 27 deletions
diff --git a/libc/stdio/_fpmaxtostr.c b/libc/stdio/_fpmaxtostr.c
index 2024caca1..99fc9a9dd 100644
--- a/libc/stdio/_fpmaxtostr.c
+++ b/libc/stdio/_fpmaxtostr.c
@@ -694,12 +694,12 @@ ssize_t attribute_hidden _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info
cnt += num_groups * tslen; /* Adjust count now for sep chars. */
-/* printf("\n"); */
+/* __printf("\n"); */
do {
if (!blk) { /* Initial group could be 0 digits long! */
blk = nblk2;
} else if (len >= blk) { /* Enough digits for a group. */
-/* printf("norm: len=%d blk=%d \"%.*s\"\n", len, blk, blk, gp); */
+/* __printf("norm: len=%d blk=%d \"%.*s\"\n", len, blk, blk, gp); */
if (fp_outfunc(fp, *ppc, blk, (intptr_t) gp) != blk) {
return -1;
}
@@ -709,9 +709,9 @@ ssize_t attribute_hidden _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info
}
len -= blk;
} else { /* Transition to 0s. */
-/* printf("trans: len=%d blk=%d \"%.*s\"\n", len, blk, len, gp); */
+/* __printf("trans: len=%d blk=%d \"%.*s\"\n", len, blk, len, gp); */
if (len) {
-/* printf("len\n"); */
+/* __printf("len\n"); */
if (fp_outfunc(fp, *ppc, len, (intptr_t) gp) != len) {
return -1;
}
@@ -719,7 +719,7 @@ ssize_t attribute_hidden _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info
}
if (ppc[3] == FPO_ZERO_PAD) { /* Need to group 0s */
-/* printf("zeropad\n"); */
+/* __printf("zeropad\n"); */
cnt += ppc[1];
ppc += 3;
gp = (const char *) ppc[2];
@@ -742,7 +742,7 @@ ssize_t attribute_hidden _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info
}
blk = nblk2;
-/* printf("num_groups=%d blk=%d\n", num_groups, blk); */
+/* __printf("num_groups=%d blk=%d\n", num_groups, blk); */
} while (1);
} else
diff --git a/libc/stdio/_stdio.h b/libc/stdio/_stdio.h
index 7dd105cce..13ecc3b4a 100644
--- a/libc/stdio/_stdio.h
+++ b/libc/stdio/_stdio.h
@@ -30,6 +30,21 @@ extern int __vfwprintf (__FILE *__restrict __s,
__const wchar_t *__restrict __format,
__gnuc_va_list __arg) attribute_hidden;
+extern int __vfscanf (FILE *__restrict __s, __const char *__restrict __format,
+ __gnuc_va_list __arg)
+ __attribute__ ((__format__ (__scanf__, 2, 0))) attribute_hidden;
+
+extern int __vsscanf (__const char *__restrict __s,
+ __const char *__restrict __format, __gnuc_va_list __arg)
+ __THROW __attribute__ ((__format__ (__scanf__, 2, 0))) attribute_hidden;
+
+extern int __vfwscanf (__FILE *__restrict __s,
+ __const wchar_t *__restrict __format,
+ __gnuc_va_list __arg) attribute_hidden;
+extern int __vswscanf (__const wchar_t *__restrict __s,
+ __const wchar_t *__restrict __format,
+ __gnuc_va_list __arg) __THROW attribute_hidden;
+
#ifdef __UCLIBC_HAS_WCHAR__
#include <wchar.h>
#endif
diff --git a/libc/stdio/fprintf.c b/libc/stdio/fprintf.c
index 07769bb59..ee19c85a5 100644
--- a/libc/stdio/fprintf.c
+++ b/libc/stdio/fprintf.c
@@ -8,6 +8,7 @@
#include "_stdio.h"
#include <stdarg.h>
+#undef fprintf
int attribute_hidden __fprintf(FILE * __restrict stream, const char * __restrict format, ...)
{
va_list arg;
diff --git a/libc/stdio/fwprintf.c b/libc/stdio/fwprintf.c
index fa5a6bdf6..c81d40482 100644
--- a/libc/stdio/fwprintf.c
+++ b/libc/stdio/fwprintf.c
@@ -15,7 +15,7 @@ int fwprintf(FILE * __restrict stream, const wchar_t * __restrict format, ...)
int rv;
va_start(arg, format);
- rv = vfwprintf(stream, format, arg);
+ rv = __vfwprintf(stream, format, arg);
va_end(arg);
return rv;
diff --git a/libc/stdio/scanf.c b/libc/stdio/scanf.c
index 555d9a267..04f30e0a5 100644
--- a/libc/stdio/scanf.c
+++ b/libc/stdio/scanf.c
@@ -147,17 +147,18 @@ _stdlib_strto_l(register const char * __restrict str,
/**********************************************************************/
#ifdef L_fscanf
-int fscanf(FILE * __restrict stream, const char * __restrict format, ...)
+int attribute_hidden __fscanf(FILE * __restrict stream, const char * __restrict format, ...)
{
va_list arg;
int rv;
va_start(arg, format);
- rv = vfscanf(stream, format, arg);
+ rv = __vfscanf(stream, format, arg);
va_end(arg);
return rv;
}
+strong_alias(__fscanf,fscanf)
#endif
/**********************************************************************/
@@ -169,7 +170,7 @@ int scanf(const char * __restrict format, ...)
int rv;
va_start(arg, format);
- rv = vfscanf(stdin, format, arg);
+ rv = __vfscanf(stdin, format, arg);
va_end(arg);
return rv;
@@ -181,17 +182,18 @@ int scanf(const char * __restrict format, ...)
#ifdef __STDIO_HAS_VSSCANF
-int sscanf(const char * __restrict str, const char * __restrict format, ...)
+int attribute_hidden __sscanf(const char * __restrict str, const char * __restrict format, ...)
{
va_list arg;
int rv;
va_start(arg, format);
- rv = vsscanf(str, format, arg);
+ rv = __vsscanf(str, format, arg);
va_end(arg);
return rv;
}
+strong_alias(__sscanf,sscanf)
#else /* __STDIO_HAS_VSSCANF */
#warning Skipping sscanf since no vsscanf!
@@ -201,10 +203,11 @@ int sscanf(const char * __restrict str, const char * __restrict format, ...)
/**********************************************************************/
#ifdef L_vscanf
-int vscanf(const char * __restrict format, va_list arg)
+int attribute_hidden __vscanf(const char * __restrict format, va_list arg)
{
- return vfscanf(stdin, format, arg);
+ return __vfscanf(stdin, format, arg);
}
+strong_alias(__vscanf,vscanf)
#endif
/**********************************************************************/
@@ -216,7 +219,7 @@ int vscanf(const char * __restrict format, va_list arg)
#ifdef __STDIO_BUFFERS
-int vsscanf(__const char *sp, __const char *fmt, va_list ap)
+int attribute_hidden __vsscanf(__const char *sp, __const char *fmt, va_list ap)
{
FILE f;
@@ -254,12 +257,13 @@ int vsscanf(__const char *sp, __const char *fmt, va_list ap)
__STDIO_STREAM_ENABLE_GETC(&f);
__STDIO_STREAM_DISABLE_PUTC(&f);
- return vfscanf(&f, fmt, ap);
+ return __vfscanf(&f, fmt, ap);
}
+strong_alias(__vsscanf,vsscanf)
#elif !defined(__UCLIBC_HAS_WCHAR__)
-int vsscanf(__const char *sp, __const char *fmt, va_list ap)
+int attribute_hidden __vsscanf(__const char *sp, __const char *fmt, va_list ap)
{
__FILE_vsscanf f;
@@ -292,23 +296,25 @@ int vsscanf(__const char *sp, __const char *fmt, va_list ap)
#endif
f.f.__nextopen = NULL;
- return vfscanf(&f.f, fmt, ap);
+ return __vfscanf(&f.f, fmt, ap);
}
+strong_alias(__vsscanf,vsscanf)
#elif defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__)
-int vsscanf(__const char *sp, __const char *fmt, va_list ap)
+int attribute_hidden __vsscanf(__const char *sp, __const char *fmt, va_list ap)
{
FILE *f;
int rv = EOF;
if ((f = fmemopen((char *)sp, __strlen(sp), "r")) != NULL) {
- rv = vfscanf(f, fmt, ap);
+ rv = __vfscanf(f, fmt, ap);
fclose(f);
}
return rv;
}
+strong_alias(__vsscanf,vsscanf)
#else
#warning Skipping vsscanf since no buffering, no custom streams, and wchar enabled!
@@ -327,7 +333,7 @@ int fwscanf(FILE * __restrict stream, const wchar_t * __restrict format, ...)
int rv;
va_start(arg, format);
- rv = vfwscanf(stream, format, arg);
+ rv = __vfwscanf(stream, format, arg);
va_end(arg);
return rv;
@@ -343,7 +349,7 @@ int wscanf(const wchar_t * __restrict format, ...)
int rv;
va_start(arg, format);
- rv = vfwscanf(stdin, format, arg);
+ rv = __vfwscanf(stdin, format, arg);
va_end(arg);
return rv;
@@ -362,7 +368,7 @@ int swscanf(const wchar_t * __restrict str, const wchar_t * __restrict format,
int rv;
va_start(arg, format);
- rv = vswscanf(str, format, arg);
+ rv = __vswscanf(str, format, arg);
va_end(arg);
return rv;
@@ -377,7 +383,7 @@ int swscanf(const wchar_t * __restrict str, const wchar_t * __restrict format,
int vwscanf(const wchar_t * __restrict format, va_list arg)
{
- return vfwscanf(stdin, format, arg);
+ return __vfwscanf(stdin, format, arg);
}
#endif
@@ -386,7 +392,7 @@ int vwscanf(const wchar_t * __restrict format, va_list arg)
#ifdef __STDIO_BUFFERS
-int vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict format,
+int attribute_hidden __vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict format,
va_list arg)
{
FILE f;
@@ -423,8 +429,9 @@ int vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict format,
#endif
f.__nextopen = NULL;
- return vfwscanf(&f, format, arg);
+ return __vfwscanf(&f, format, arg);
}
+strong_alias(__vswscanf,vswscanf)
#else /* __STDIO_BUFFERS */
#warning Skipping vswscanf since no buffering!
#endif /* __STDIO_BUFFERS */
@@ -573,6 +580,7 @@ enum {
#define Wchar wchar_t
#define Wuchar __uwchar_t
#define ISSPACE(C) iswspace((C))
+#define HIDDEN_VFSCANF __vfwscanf
#define VFSCANF vfwscanf
#define GETC(SC) (SC)->sc_getc((SC))
#else
@@ -582,6 +590,7 @@ typedef unsigned char __uchar_t;
#define Wchar char
#define Wuchar __uchar_t
#define ISSPACE(C) isspace((C))
+#define HIDDEN_VFSCANF __vfscanf
#define VFSCANF vfscanf
#ifdef __UCLIBC_HAS_WCHAR__
#define GETC(SC) (SC)->sc_getc((SC))
@@ -1139,7 +1148,7 @@ static const char fake_thousands_sep_str[] = ",";
#endif /* L_vfwscanf */
-int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
+int attribute_hidden HIDDEN_VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
{
const Wuchar *fmt;
unsigned char *b;
@@ -1743,6 +1752,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
return psfs.cnt;
}
+strong_alias(HIDDEN_VFSCANF,VFSCANF)
#endif
/**********************************************************************/
#ifdef L___psfs_do_numeric