scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit f75308d46c6b043f5b284fae0e149352f01f839c
parent ce4378b51b24fbceed1bf8308dac1df7ded3aa59
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon,  4 Dec 2017 21:43:02 +0100

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

Diffstat:
Mlib/c/src/Makefile | 2+-
Alib/c/src/fputs.c | 12++++++++++++
Alib/c/src/puts.c | 12++++++++++++
3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/lib/c/src/Makefile b/lib/c/src/Makefile @@ -12,7 +12,7 @@ OBJ = assert.o strcpy.o strcmp.o strlen.o strchr.o \ 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 diff --git a/lib/c/src/fputs.c b/lib/c/src/fputs.c @@ -0,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; +} diff --git a/lib/c/src/puts.c b/lib/c/src/puts.c @@ -0,0 +1,12 @@ + +#include <stdio.h> + +int +puts(const char *str) +{ + int ch; + + while (ch = *str) + putchar(ch); + return putchar('\n'); +}