ref: dde4464771221d88577149222e38612b18cac4ce
parent: 2d455f13954cd94ae98ed346bb7da23d579ad6d7
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Dec 6 10:22:13 EST 2017
[lib/c] Add feof(), ferror() and clearerr()
--- a/lib/c/src/Makefile
+++ b/lib/c/src/Makefile
@@ -8,6 +8,7 @@
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 \
--- /dev/null
+++ b/lib/c/src/clearerr.c
@@ -1,0 +1,9 @@
+
+#include <stdio.h>
+#undef clearerr
+
+void
+clearerr(FILE *fp)
+{
+ fp->flags &= ~(_IOERR | _IOEOF);
+}
--- /dev/null
+++ b/lib/c/src/feof.c
@@ -1,0 +1,9 @@
+
+#include <stdio.h>
+#undef feof
+
+int
+feof(FILE *fp)
+{
+ return fp->flags & _IOEOF;
+}
--- /dev/null
+++ b/lib/c/src/ferror.c
@@ -1,0 +1,9 @@
+
+#include <stdio.h>
+#undef ferror
+
+int
+ferror(FILE *fp)
+{
+ return fp->flags & _IOERR;
+}