aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib/ungetc.c
diff options
context:
space:
mode:
Diffstat (limited to 'com32/lib/ungetc.c')
-rw-r--r--com32/lib/ungetc.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/com32/lib/ungetc.c b/com32/lib/ungetc.c
new file mode 100644
index 00000000..b8ffca98
--- /dev/null
+++ b/com32/lib/ungetc.c
@@ -0,0 +1,18 @@
+/*
+ * ungetc.c
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+
+int ungetc(int c, FILE *f)
+{
+ unsigned char ch = c;
+
+ if (unread(fileno(f), &ch, 1) == 1)
+ return ch;
+ else
+ return EOF;
+}