]> git.sur5r.net Git - cc65/blobdiff - libsrc/common/fgetc.c
The spans do now contain the size of a span, no longer the end offset.
[cc65] / libsrc / common / fgetc.c
index c7d30d4bcbd087ab62ac3feb553f1ace4a1f9648..7e6a4db9cac2a16e63663e7170deb6726eb076fe 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <stdio.h>
 #include <unistd.h>
-#include <errno.h>
 #include "_file.h"
 
 
@@ -20,7 +19,7 @@
 
 
 
-int fgetc (FILE* f)
+int __fastcall__ fgetc (register FILE* f)
 {
     unsigned char c;
 
@@ -29,7 +28,13 @@ int fgetc (FILE* f)
        return EOF;
     }
 
-    /* Read the byte */
+    /* If we have a pushed back character, return it */
+    if (f->f_flags & _FPUSHBACK) {
+        f->f_flags &= ~_FPUSHBACK;
+        return f->f_pushback;
+    }
+
+    /* Read one byte */
     switch (read (f->f_fd, &c, 1)) {
 
         case -1: