Tue Jan 16 17:37:39 1996 Roland McGrath <roland@churchy.gnu.ai.mit.edu>

* csu/Makefile [have-initfini=yes] (CPPFLAGS): Append -DHAVE_INITFINI.
	(initfini): Compile initfini.c with -fPIC.

Sun Jan 14 17:51:09 1996  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* stdio-common/vfscanf.c (inchar, conv_error, input_error,
	memory_error): Add cast to void to avoid gcc warning.
	(vfscanf): Rewrite character class parsing to make it more efficient.
This commit is contained in:
Roland McGrath 1996-01-17 01:46:13 +00:00
parent da128169aa
commit b17178fc56
2 changed files with 51 additions and 25 deletions

View File

@ -1,3 +1,14 @@
Tue Jan 16 17:37:39 1996 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* csu/Makefile [have-initfini=yes] (CPPFLAGS): Append -DHAVE_INITFINI.
(initfini): Compile initfini.c with -fPIC.
Sun Jan 14 17:51:09 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* stdio-common/vfscanf.c (inchar, conv_error, input_error,
memory_error): Add cast to void to avoid gcc warning.
(vfscanf): Rewrite character class parsing to make it more efficient.
Sun Jan 14 01:01:10 1996 Ulrich Drepper <drepper@ipd.info.uni-karlsruhe.de> Sun Jan 14 01:01:10 1996 Ulrich Drepper <drepper@ipd.info.uni-karlsruhe.de>
* stdlib/strtol.c: Return correct pointer for strings * stdlib/strtol.c: Return correct pointer for strings

View File

@ -50,13 +50,13 @@ Cambridge, MA 02139, USA. */
# define va_list _IO_va_list # define va_list _IO_va_list
# define ungetc(c, s) _IO_ungetc (c, s) # define ungetc(c, s) _IO_ungetc (c, s)
# define inchar() ((c = _IO_getc (s)), ++read_in, c) # define inchar() ((c = _IO_getc (s)), (void) ++read_in, c)
# define conv_error() return ((errp != NULL && (*errp |= 2)), \ # define conv_error() return ((void) (errp != NULL && (*errp |= 2)), \
(c == EOF || _IO_ungetc (c, s)), done) (void) (c == EOF || _IO_ungetc (c, s)), done)
# define input_error() return ((errp != NULL && (*errp |= 1)), \ # define input_error() return ((void) (errp != NULL && (*errp |= 1)), \
done == 0 ? EOF : done) done == 0 ? EOF : done)
# define memory_error() return ((errno = ENOMEM), EOF) # define memory_error() return ((void) (errno = ENOMEM), EOF)
# define ARGCHECK(s, format) \ # define ARGCHECK(s, format) \
do \ do \
{ \ { \
@ -69,10 +69,10 @@ Cambridge, MA 02139, USA. */
} \ } \
} while (0) } while (0)
#else #else
# define inchar() ((c = getc (s)), ++read_in, c) # define inchar() ((c = getc (s)), (void) ++read_in, c)
# define conv_error() return (ungetc (c, s), done) # define conv_error() return ((void) ungetc (c, s), done)
# define input_error() return (done == 0 ? EOF : done) # define input_error() return (done == 0 ? EOF : done)
# define memory_error() return ((errno = ENOMEM), EOF) # define memory_error() return ((void) (errno = ENOMEM), EOF)
# define ARGCHECK(s, format) \ # define ARGCHECK(s, format) \
do \ do \
{ \ { \
@ -104,7 +104,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
va_list arg = (va_list) argptr; va_list arg = (va_list) argptr;
register const char *f = format; register const char *f = format;
register char fc; /* Current character of the format. */ register unsigned char fc; /* Current character of the format. */
register size_t done = 0; /* Assignments done. */ register size_t done = 0; /* Assignments done. */
register size_t read_in = 0; /* Chars read in. */ register size_t read_in = 0; /* Chars read in. */
register int c; /* Last char read. */ register int c; /* Last char read. */
@ -158,7 +158,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
if (wpsize == wpmax) \ if (wpsize == wpmax) \
{ \ { \
char *old = wp; \ char *old = wp; \
wpmax = 200 > 2 * wpmax ? 200 : 2 * wpmax; \ wpmax = UCHAR_MAX > 2 * wpmax ? UCHAR_MAX : 2 * wpmax; \
wp = (char *) alloca (wpmax); \ wp = (char *) alloca (wpmax); \
if (old != NULL) \ if (old != NULL) \
memcpy (wp, old, wpsize); \ memcpy (wp, old, wpsize); \
@ -703,31 +703,46 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
else else
not_in = 0; not_in = 0;
if (*f == ']') /* Fill WP with byte flags indexed by character.
/* If ] appears before any char in the set, it is not We will use this flag map for matching input characters. */
the terminator, but the first char in the set. */ if (wpmax < UCHAR_MAX)
ADDW (*f++); {
wpmax = UCHAR_MAX;
wp = (char *) alloca (wpmax);
}
memset (wp, 0, UCHAR_MAX);
fc = *f;
if (fc == ']' || fc == '-')
{
/* If ] or - appears before any char in the set, it is not
the terminator or separator, but the first char in the
set. */
wp[fc] = 1;
++f;
}
while ((fc = *f++) != '\0' && fc != ']') while ((fc = *f++) != '\0' && fc != ']')
{ {
if (fc == '-' && *f != '\0' && *f != ']' && if (*f == '-' && f[1] != '\0' && f[1] != ']' && fc <= f[1])
wpsize > 0 && wp[wpsize - 1] <= *f) {
/* Add all characters from the one before the '-' /* Add all characters from the one before the '-'
up to (but not including) the next format char. */ up to (but not including) the next format char. */
for (fc = wp[wpsize - 1] + 1; fc < *f; ++fc) f++;
ADDW (fc); while (fc < *f)
wp[fc++] = 1;
}
else else
/* Add the character to the list. */ /* Add the character to the flag map. */
ADDW (fc); wp[fc] = 1;
} }
if (fc == '\0') if (fc == '\0')
conv_error(); conv_error();
ADDW ('\0');
num.ul = read_in; num.ul = read_in;
do do
{ {
if ((strchr (wp, c) == NULL) != not_in) if (wp[c] == not_in)
break; break;
STRING_ADD_CHAR (c); STRING_ADD_CHAR (c);
if (width > 0) if (width > 0)
@ -758,7 +773,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
while (isspace (c)) while (isspace (c))
(void) inchar (); (void) inchar ();
return ((c == EOF || ungetc (c, s)), done); return ((void) (c == EOF || ungetc (c, s)), done);
} }
#ifdef USE_IN_LIBIO #ifdef USE_IN_LIBIO