]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - libio/genops.c
Thu Mar 28 03:25:10 1996 Roland McGrath <roland@charlie-brown.gnu.ai.mit.edu>
[thirdparty/glibc.git] / libio / genops.c
index 7eb2d43ee1956f681d59988709e6aaf22a01c2f7..23a6fdeaeac7bb5d8e076f0f59adeda14389b208 100644 (file)
@@ -511,26 +511,41 @@ int
 DEFUN(_IO_sputbackc, (fp, c),
       register _IO_FILE *fp AND int c)
 {
+  int result;
+  
   if (fp->_IO_read_ptr > fp->_IO_read_base
       && (unsigned char)fp->_IO_read_ptr[-1] == (unsigned char)c)
     {
       fp->_IO_read_ptr--;
-      return (unsigned char)c;
+      result = (unsigned char)c;
     }
-  return _IO_PBACKFAIL (fp, c);
+  else
+    result = _IO_PBACKFAIL (fp, c);
+
+  if (result != EOF)
+    fp->_flags &= ~_IO_EOF_SEEN;
+
+  return result;
 }
 
 int
 DEFUN(_IO_sungetc, (fp),
       register _IO_FILE *fp)
 {
+  int result;
+  
   if (fp->_IO_read_ptr > fp->_IO_read_base)
     {
       fp->_IO_read_ptr--;
-      return (unsigned char)*fp->_IO_read_ptr;
+      result = (unsigned char)*fp->_IO_read_ptr;
     }
   else
-    return _IO_PBACKFAIL (fp, EOF);
+    result = _IO_PBACKFAIL (fp, EOF);
+
+  if (result != EOF)
+    fp->_flags &= ~_IO_EOF_SEEN;
+
+  return result;
 }
 
 #if 0 /* Work in progress */