shithub: scc

Download patch

ref: 6ae6f05f761a36086f80e78c018a77c0e8ee0fbb
parent: c40195789a26f30a3130d44f9ecd8758ea0eb0d4
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Dec 4 16:43:02 EST 2017

[lib/c] Add puts() and fputs()

--- a/lib/c/src/Makefile
+++ b/lib/c/src/Makefile
@@ -12,7 +12,7 @@
       localeconv.o atoi.o atol.o atoll.o atexit.o exit.o \
       printf.o fprintf.o vfprintf.o \
       fgets.o gets.of fgetc.o fputc.o getchar.o putchar.o \
-      fread.o fwrite.o \
+      fputs.o puts.o fread.o fwrite.o \
       realloc.o calloc.o malloc.o
 
 all: $(ARCH)-libc.a
--- /dev/null
+++ b/lib/c/src/fputs.c
@@ -1,0 +1,12 @@
+
+#include <stdio.h>
+
+int
+fputs(const char * restrict bp, FILE * restrict fp)
+{
+	int r, ch;
+
+	while (ch = *bp++)
+		r = putc(ch, fp);
+	return r;
+}
--- /dev/null
+++ b/lib/c/src/puts.c
@@ -1,0 +1,12 @@
+
+#include <stdio.h>
+
+int
+puts(const char *str)
+{
+	int ch;
+
+	while (ch = *str)
+		putchar(ch);
+	return putchar('\n');
+}