commit 346d4d01e0614d93034e8b4209a1e91e4504ea02
parent 4dd5500352c42601000a36152c10b044f96cb352
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 6 Dec 2017 15:22:13 +0000
[lib/c] Add feof(), ferror() and clearerr()
Diffstat:
4 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/lib/c/src/Makefile b/lib/c/src/Makefile
@@ -8,6 +8,7 @@ OBJ = bsearch.o \
fgets.o gets.of fgetc.o fputc.o getchar.o putchar.o \
fputs.o puts.o fread.o fwrite.o \
getc.o putc.o __putc.o __getc.o \
+ ferror.o feof.o clearerr.o \
realloc.o calloc.o malloc.o \
assert.o strcpy.o strcmp.o strlen.o strchr.o \
strrchr.o strcat.o strncmp.o strncpy.o strncat.o strcoll.o \
diff --git a/lib/c/src/clearerr.c b/lib/c/src/clearerr.c
@@ -0,0 +1,9 @@
+
+#include <stdio.h>
+#undef clearerr
+
+void
+clearerr(FILE *fp)
+{
+ fp->flags &= ~(_IOERR | _IOEOF);
+}
diff --git a/lib/c/src/feof.c b/lib/c/src/feof.c
@@ -0,0 +1,9 @@
+
+#include <stdio.h>
+#undef feof
+
+int
+feof(FILE *fp)
+{
+ return fp->flags & _IOEOF;
+}
diff --git a/lib/c/src/ferror.c b/lib/c/src/ferror.c
@@ -0,0 +1,9 @@
+
+#include <stdio.h>
+#undef ferror
+
+int
+ferror(FILE *fp)
+{
+ return fp->flags & _IOERR;
+}