From 7c233246d6d332dd9db897e8b9a0dd8abc49efd0 Mon Sep 17 00:00:00 2001 From: rain1 Date: Sun, 30 Jul 2017 08:28:19 -0400 Subject: [PATCH] mescc: Tinycc support: fgetc. * mlibc/libc-mes.c (fgetc): Implement. --- mlibc/libc-mes.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mlibc/libc-mes.c b/mlibc/libc-mes.c index 9aaf3909..1a351eda 100644 --- a/mlibc/libc-mes.c +++ b/mlibc/libc-mes.c @@ -216,6 +216,14 @@ getchar () return i; } +int +fgetc (int fd) +{ + char c; + int r = read (fd, &c, 1); + return c == 1 ? c : (-1); +} + //#define assert(x) ((x) ? (void)0 : assert_fail (#x)) int ungetc (int c, int fd)