From: cuz Date: Thu, 13 May 2004 21:13:51 +0000 (+0000) Subject: Add support for pushed back chars X-Git-Tag: V2.12.0~797 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=35aea65c6127f93defb9405690234281915e114b;p=cc65 Add support for pushed back chars git-svn-id: svn://svn.cc65.org/cc65/trunk@3033 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/libsrc/common/fgetc.c b/libsrc/common/fgetc.c index c84d8e662..cb2f75f80 100644 --- a/libsrc/common/fgetc.c +++ b/libsrc/common/fgetc.c @@ -20,7 +20,7 @@ -int __fastcall__ fgetc (FILE* f) +int __fastcall__ fgetc (register FILE* f) { unsigned char c; @@ -29,7 +29,13 @@ int __fastcall__ 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: