summaryrefslogtreecommitdiffstats
path: root/fgetc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fgetc.c')
-rw-r--r--fgetc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/fgetc.c b/fgetc.c
index fd1e611..7da6b24 100644
--- a/fgetc.c
+++ b/fgetc.c
@@ -32,11 +32,16 @@ my_fgetc(FILE * input)
/* Pushes character back on input. */
/* =============================== */
void
-my_ungetc(int c)
+my_ungetc(int c, FILE * input)
{
if (next_buffer_pos >= GETC_BUFF_SIZE)
fprintf(stderr, "Error: cannot push back more than %d characters\n",
GETC_BUFF_SIZE);
else
+ {
getc_buffer[next_buffer_pos++] = c;
+
+ if (feof(input))
+ clearerr(input); /* No more EOF. */
+ }
}