shithub: scc

Download patch

ref: da7698a0ff0faf4e02663430914b384a2f7276eb
parent: 37e4ca9b85b68ca0441c18c2f4fbf24c866e38cb
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Dec 4 08:35:03 EST 2017

[lib/c] Add fgetc(), fputc(), getchar() and putchar()

--- a/lib/c/src/Makefile
+++ b/lib/c/src/Makefile
@@ -11,7 +11,7 @@
       isxdigit.o toupper.o tolower.o ctype.o setlocale.o \
       localeconv.o atoi.o atol.o atoll.o atexit.o exit.o \
       printf.o fprintf.o vfprintf.o \
-      fgets.o gets.o \
+      fgets.o gets.of fgetc.o fputc.o getchar.o putchar.o \
       realloc.o calloc.o malloc.o
 
 all: $(ARCH)-libc.a
--- /dev/null
+++ b/lib/c/src/fgetc.c
@@ -1,0 +1,9 @@
+
+#include <stdio.h>
+#undef fgetc
+
+int
+fgetc(FILE *fp)
+{
+	return getc(fp);
+}
--- /dev/null
+++ b/lib/c/src/fputc.c
@@ -1,0 +1,9 @@
+
+#include <stdio.h>
+#undef fputc
+
+int
+fputc(int c, FILE *fp)
+{
+	return putc(c, fp);
+}
--- /dev/null
+++ b/lib/c/src/getchar.c
@@ -1,0 +1,9 @@
+
+#include <stdio.h>
+#undef getchar
+
+int
+getchar(void)
+{
+	return getc(stdin);
+}
--- /dev/null
+++ b/lib/c/src/putchar.c
@@ -1,0 +1,9 @@
+
+#include <stdio.h>
+#undef putchar
+
+int
+putchar(int ch)
+{
+	return putc(ch, stdin);
+}