Index: fusl/src/stdio/ungetc.c |
diff --git a/fusl/src/stdio/ungetc.c b/fusl/src/stdio/ungetc.c |
new file mode 100644 |
index 0000000000000000000000000000000000000000..180673a47663ad57b11d3e6525c35cc23858939a |
--- /dev/null |
+++ b/fusl/src/stdio/ungetc.c |
@@ -0,0 +1,20 @@ |
+#include "stdio_impl.h" |
+ |
+int ungetc(int c, FILE *f) |
+{ |
+ if (c == EOF) return c; |
+ |
+ FLOCK(f); |
+ |
+ if (!f->rpos) __toread(f); |
+ if (!f->rpos || f->rpos <= f->buf - UNGET) { |
+ FUNLOCK(f); |
+ return EOF; |
+ } |
+ |
+ *--f->rpos = c; |
+ f->flags &= ~F_EOF; |
+ |
+ FUNLOCK(f); |
+ return c; |
+} |