diff options
author | 1997-03-17 03:59:42 +0000 | |
---|---|---|
committer | 1997-03-17 03:59:42 +0000 | |
commit | 2047317f3b3d746b001150aa79bbb7b2a9b14f81 (patch) | |
tree | d9cee7d77095dd0f3e675f368981771b0ce35bd0 | |
parent | (vasprintf): Give full prototype. (diff) | |
download | glibc-2047317f3b3d746b001150aa79bbb7b2a9b14f81.tar.gz glibc-2047317f3b3d746b001150aa79bbb7b2a9b14f81.tar.bz2 glibc-2047317f3b3d746b001150aa79bbb7b2a9b14f81.zip |
Use __va_copy if available.
-rw-r--r-- | stdio-common/vfscanf.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c index f201c46775..256f3eab33 100644 --- a/stdio-common/vfscanf.c +++ b/stdio-common/vfscanf.c @@ -163,8 +163,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) #endif { - va_list arg = (va_list) argptr; - + va_list arg; register const char *f = format; register unsigned char fc; /* Current character of the format. */ register size_t done = 0; /* Assignments done. */ @@ -222,6 +221,12 @@ __vfscanf (FILE *s, const char *format, va_list argptr) } \ while (0) +#ifdef __va_copy + __va_copy (arg, argptr); +#else + arg = (va_list) argptr; +#endif + ARGCHECK (s, format); /* Figure out the decimal point character. */ @@ -243,23 +248,34 @@ __vfscanf (FILE *s, const char *format, va_list argptr) /* Extract the next argument, which is of type TYPE. For a %N$... spec, this is the Nth argument from the beginning; otherwise it is the next argument after the state now in ARG. */ -#if 0 +#ifdef __va_copy +# define ARG(type) (argpos == 0 ? va_arg (arg, type) : \ + ({ unsigned int pos = argpos; \ + va_list arg; \ + __va_copy (arg, argptr); \ + while (--pos > 0) \ + (void) va_arg (arg, void *); \ + va_arg (arg, type); \ + })) +#else +# if 0 /* XXX Possible optimization. */ -# define ARG(type) (argpos == 0 ? va_arg (arg, type) : \ +# define ARG(type) (argpos == 0 ? va_arg (arg, type) : \ ({ va_list arg = (va_list) argptr; \ arg = (va_list) ((char *) arg \ + (argpos - 1) \ * __va_rounded_size (void *)); \ va_arg (arg, type); \ })) -#else -# define ARG(type) (argpos == 0 ? va_arg (arg, type) : \ +# else +# define ARG(type) (argpos == 0 ? va_arg (arg, type) : \ ({ unsigned int pos = argpos; \ va_list arg = (va_list) argptr; \ while (--pos > 0) \ (void) va_arg (arg, void *); \ va_arg (arg, type); \ })) +# endif #endif if (!isascii (*f)) |