# define TYPEMOD (LONG|LONGDBL|SHORT)
-# define ungetc(c, s) ((void) (c != EOF && --read_in), ungetc (c, s))
+# define UNGETC(c, s) ((void) (((wint_t)c) != ((wint_t)EOF) && --read_in), ungetc (c, s))
# define inchar() ((c = getc (s)), (void) (c != EOF && ++read_in), c)
# define encode_error() do { \
funlockfile (s); \
# define flockfile(S) /* nothing */
# define funlockfile(S) /* nothing */
- char *wp = NULL; /* Workspace. */
- size_t wpmax = 0; /* Maximal size of workspace. */
- size_t wpsize = 0; /* Currently used bytes in workspace. */
-
-
-void ADDW(int Ch) \
-{
- if (wpsize == wpmax)
- {
- char *old = wp;
- wpmax = UCHAR_MAX > 2 * wpmax ? UCHAR_MAX : 2 * wpmax;
- wp = (char *) malloc (wpmax);
- if (old != NULL) {
- memcpy (wp, old, wpsize);
- free(old);
- }
- }
- wp[wpsize++] = (Ch);
-}
+# define ADDW(Ch) \
+do{ \
+ if (wpsize == wpmax) \
+ { \
+ char *old = wp; \
+ wpmax = UCHAR_MAX > 2 * wpmax ? UCHAR_MAX : 2 * wpmax; \
+ wp = (char *) malloc (wpmax); \
+ if (old != NULL) \
+ { \
+ memcpy (wp, old, wpsize); \
+ free(old); \
+ } \
+ } \
+ wp[wpsize++] = (Ch); \
+}while(0)
int __vfscanf (FILE *s, const char *format, va_list argptr)
available anymore. */
int skip_space = 0;
/* Workspace. */
+ char *wp = NULL; /* Workspace. */
+ size_t wpmax = 0; /* Maximal size of workspace. */
+ size_t wpsize = 0; /* Currently used bytes in workspace. */
char *tw; /* Temporary pointer. */
#ifdef __va_copy
input_error ();
else if (c != *f++)
{
- ungetc (c, s);
+ UNGETC (c, s);
conv_error ();
}
}
if (skip_space)
{
while (isspace (c))
- if (inchar () == EOF && errno == EINTR)
+ if (inchar () == EOF && *_errno() == EINTR)
conv_error ();
skip_space = 0;
}
if (c != fc)
{
- ungetc (c, s);
+ UNGETC (c, s);
conv_error ();
}
conv_error ();
/* We must take care for EINTR errors. */
- if (c == EOF && errno == EINTR)
+ if (c == EOF && *_errno() == EINTR)
input_error ();
/* Find the conversion specifier. */
{
/* Eat whitespace. */
do
- if (inchar () == EOF && errno == EINTR)
+ if (inchar () == EOF && *_errno() == EINTR)
input_error ();
while (isspace (c));
- ungetc (c, s);
+ UNGETC (c, s);
skip_space = 0;
}
c = inchar ();
if (c != fc)
{
- ungetc (c, s);
+ UNGETC (c, s);
conv_error ();
}
break;
{
if (isspace (c))
{
- ungetc (c, s);
+ UNGETC (c, s);
break;
}
#define STRING_ADD_CHAR(Str, c, Type) \
not make a difference for white space characters
we can simply push back a simple <SP> which is
guaranteed to be in the [:space:] class. */
- ungetc (' ', s);
+ UNGETC (' ', s);
break;
}
}
/* The just read character is not part of the number anymore. */
- ungetc (c, s);
+ UNGETC (c, s);
if (wpsize == 0 ||
(wpsize == 1 && (wp[0] == '+' || wp[0] == '-')))
{
/* The last read character is not part of the number
anymore. */
- ungetc (c, s);
+ UNGETC (c, s);
break;
}
if (width > 0)
if (fc == '\0')
{
if (!(flags & LONG))
- ungetc (c, s);
+ UNGETC (c, s);
conv_error();
}
input we push it back only in case it is
representable within one byte. */
if (val < 0x80)
- ungetc (val, s);
+ UNGETC (val, s);
break;
}
STRING_ADD_CHAR (wstr, val, wchar_t);
{
if (wp[c] == not_in)
{
- ungetc (c, s);
+ UNGETC (c, s);
break;
}
STRING_ADD_CHAR (str, c, char);
do
c = inchar ();
while (isspace (c));
- ungetc (c, s);
+ UNGETC (c, s);
}