summaryrefslogtreecommitdiff
path: root/libc/stdio-common/vfscanf.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/stdio-common/vfscanf.c')
-rw-r--r--libc/stdio-common/vfscanf.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/libc/stdio-common/vfscanf.c b/libc/stdio-common/vfscanf.c
index b1469b9a9..9e6daced5 100644
--- a/libc/stdio-common/vfscanf.c
+++ b/libc/stdio-common/vfscanf.c
@@ -530,12 +530,17 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
{
/* Eat whitespace. */
int save_errno = errno;
- errno = 0;
+ __set_errno (0);
do
- if (__builtin_expect (inchar () == EOF && errno == EINTR, 0))
+ /* We add the additional test for EOF here since otherwise
+ inchar will restore the old errno value which might be
+ EINTR but does not indicate an interrupt since nothing
+ was read at this time. */
+ if (__builtin_expect ((c == EOF || inchar () == EOF)
+ && errno == EINTR, 0))
input_error ();
while (ISSPACE (c));
- errno = save_errno;
+ __set_errno (save_errno);
ungetc (c, s);
skip_space = 0;
}