1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-04-26 15:09:05 +03:00
* stdio-common/vfscanf.c (_IO_vfscanf): Likewise.
This commit is contained in:
Ulrich Drepper 1999-05-25 13:49:30 +00:00
parent 0ae97dea38
commit 96d0213ee1
2 changed files with 17 additions and 9 deletions

View File

@ -2,6 +2,7 @@
* stdio-common/vfprintf.c (vfprintf): Don't implement special * stdio-common/vfprintf.c (vfprintf): Don't implement special
handling for long long if it is the same as long. handling for long long if it is the same as long.
* stdio-common/vfscanf.c (_IO_vfscanf): Likewise.
* stdlib/strtol.c: Moved to ... * stdlib/strtol.c: Moved to ...
* sysdeps/generic/strtol.c: ...here. * sysdeps/generic/strtol.c: ...here.

View File

@ -36,6 +36,13 @@
# define LONGLONG long # define LONGLONG long
#endif #endif
/* Determine whether we have to handle `long long' at all. */
#if LONG_MAX == LONG_LONG_MAX
# define need_longlong 0
#else
# define need_longlong 1
#endif
/* Those are flags in the conversion format. */ /* Those are flags in the conversion format. */
# define LONG 0x001 /* l: long or double */ # define LONG 0x001 /* l: long or double */
# define LONGDBL 0x002 /* L: long long or long double */ # define LONGDBL 0x002 /* L: long long or long double */
@ -439,7 +446,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
{ {
/* A double `l' is equivalent to an `L'. */ /* A double `l' is equivalent to an `L'. */
++f; ++f;
flags |= LONGDBL; flags |= need_longlong ? LONGDBL | LONG;
} }
else else
/* ints are long ints. */ /* ints are long ints. */
@ -448,7 +455,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
case 'q': case 'q':
case 'L': case 'L':
/* doubles are long doubles, and ints are long long ints. */ /* doubles are long doubles, and ints are long long ints. */
flags |= LONGDBL; flags |= need_longlong ? LONGDBL | LONG;
break; break;
case 'a': case 'a':
/* The `a' is used as a flag only if followed by `s', `S' or /* The `a' is used as a flag only if followed by `s', `S' or
@ -463,19 +470,19 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
flags |= MALLOC; flags |= MALLOC;
break; break;
case 'z': case 'z':
if (sizeof (size_t) > sizeof (unsigned long int)) if (need_longlong && sizeof (size_t) > sizeof (unsigned long int))
flags |= LONGDBL; flags |= LONGDBL;
else if (sizeof (size_t) > sizeof (unsigned int)) else if (sizeof (size_t) > sizeof (unsigned int))
flags |= LONG; flags |= LONG;
break; break;
case 'j': case 'j':
if (sizeof (uintmax_t) > sizeof (unsigned long int)) if (need_longlong && sizeof (uintmax_t) > sizeof (unsigned long int))
flags |= LONGDBL; flags |= LONGDBL;
else if (sizeof (uintmax_t) > sizeof (unsigned int)) else if (sizeof (uintmax_t) > sizeof (unsigned int))
flags |= LONG; flags |= LONG;
break; break;
case 't': case 't':
if (sizeof (ptrdiff_t) > sizeof (long int)) if (need_longlong && sizeof (ptrdiff_t) > sizeof (long int))
flags |= LONGDBL; flags |= LONGDBL;
else if (sizeof (ptrdiff_t) > sizeof (int)) else if (sizeof (ptrdiff_t) > sizeof (int))
flags |= LONG; flags |= LONG;
@ -525,7 +532,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
if (!(flags & SUPPRESS)) if (!(flags & SUPPRESS))
{ {
/* Don't count the read-ahead. */ /* Don't count the read-ahead. */
if (flags & LONGDBL) if (need_longlong && (flags & LONGDBL))
*ARG (long long int *) = read_in; *ARG (long long int *) = read_in;
else if (flags & LONG) else if (flags & LONG)
*ARG (long int *) = read_in; *ARG (long int *) = read_in;
@ -916,7 +923,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
/* Convert the number. */ /* Convert the number. */
ADDW ('\0'); ADDW ('\0');
if (flags & LONGDBL) if (need_longlong && (flags & LONGDBL))
{ {
if (number_signed) if (number_signed)
num.q = __strtoll_internal (wp, &tw, base, flags & GROUP); num.q = __strtoll_internal (wp, &tw, base, flags & GROUP);
@ -937,7 +944,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
{ {
if (! number_signed) if (! number_signed)
{ {
if (flags & LONGDBL) if (need_longlong && (flags & LONGDBL))
*ARG (unsigned LONGLONG int *) = num.uq; *ARG (unsigned LONGLONG int *) = num.uq;
else if (flags & LONG) else if (flags & LONG)
*ARG (unsigned long int *) = num.ul; *ARG (unsigned long int *) = num.ul;
@ -951,7 +958,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
} }
else else
{ {
if (flags & LONGDBL) if (need_longlong && (flags & LONGDBL))
*ARG (LONGLONG int *) = num.q; *ARG (LONGLONG int *) = num.q;
else if (flags & LONG) else if (flags & LONG)
*ARG (long int *) = num.l; *ARG (long int *) = num.l;