about summary refs log tree commit diff
path: root/stdio-common
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-07-11 08:33:33 +0000
committerUlrich Drepper <drepper@redhat.com>2002-07-11 08:33:33 +0000
commit7d68a8ec676b26556393ea0ef067dddb1b5fc24f (patch)
treec1a45c86c1e22ae176b7a822e6d223a67186b915 /stdio-common
parent52e1b618f4a5a161b16d2d14bac74b685097eccb (diff)
downloadglibc-7d68a8ec676b26556393ea0ef067dddb1b5fc24f.tar.gz
glibc-7d68a8ec676b26556393ea0ef067dddb1b5fc24f.tar.xz
glibc-7d68a8ec676b26556393ea0ef067dddb1b5fc24f.zip
Update.
2002-07-11  Ulrich Drepper  <drepper@redhat.com>

	* stdio-common/vfscanf.c (inchar): Restore errno from previous
	underflow operation if c == (W)EOF.
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/vfscanf.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index 9586ab6890..b563a04b38 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -78,9 +78,10 @@
 				     INTUSE(_IO_sputbackwc) (s, c))))
 #  define ungetc_not_eof(c, s)	((void) (--read_in,			      \
 					 INTUSE(_IO_sputbackwc) (s, c)))
-#  define inchar()	(c == WEOF ? WEOF				      \
+#  define inchar()	(c == WEOF ? ((errno = inchar_errno), WEOF)	      \
 			 : ((c = _IO_getwc_unlocked (s)),		      \
-			    (void) (c != WEOF && ++read_in), c))
+			    (void) (c != WEOF				      \
+				    ? ++read_in : (inchar_errno = errno)), c))
 
 #  define MEMCPY(d, s, n) __wmemcpy (d, s, n)
 #  define ISSPACE(Ch)	  iswspace (Ch)
@@ -108,9 +109,10 @@
 				     INTUSE(_IO_sputbackc) (s, (unsigned char) c))))
 #  define ungetc_not_eof(c, s)	((void) (--read_in,			      \
 					 INTUSE(_IO_sputbackc) (s, (unsigned char) c)))
-#  define inchar()	(c == EOF ? EOF					      \
+#  define inchar()	(c == EOF ? ((errno = inchar_errno), EOF)	      \
 			 : ((c = _IO_getc_unlocked (s)),		      \
-			    (void) (c != EOF && ++read_in), c))
+			    (void) (c != EOF				      \
+				    ? ++read_in : (inchar_errno = errno)), c))
 #  define MEMCPY(d, s, n) memcpy (d, s, n)
 #  define ISSPACE(Ch)	  isspace (Ch)
 #  define ISDIGIT(Ch)	  isdigit (Ch)
@@ -272,6 +274,8 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
   register int width;		/* Maximum field width.  */
   register int flags;		/* Modifiers for current format element.  */
 
+  /* Errno of last failed inchar call.  */
+  int inchar_errno = 0;
   /* Status for reading F-P nums.  */
   char got_dot, got_e, negative;
   /* If a [...] is a [^...].  */