Permalink
Browse files

Stubbed the <stdio.h> feof(), fgetc(), getc(), getchar() functions.

  • Loading branch information...
bendiken committed Nov 23, 2014
1 parent f6e8f37 commit 1fb46d09e8b1d65098e186e6f18d23a8cedea03f
Showing with 95 additions and 2 deletions.
  1. +2 −2 TODO
  2. +15 −0 src/include/stdio.h
  3. +4 −0 src/stdio/Makefile.am
  4. +20 −0 src/stdio/feof.c
  5. +18 −0 src/stdio/fgetc.c
  6. +18 −0 src/stdio/getc.c
  7. +18 −0 src/stdio/getchar.c
View
4 TODO
@@ -6,8 +6,8 @@ Release 0.1.0 ("Hello, world!")
- <signal.h>: raise().
~ <stdlib.h>: abort().
- <assert.h>: assert().
-- Implement more of <stdio.h>:
- - <stdio.h>: feof(), fgetc(), getc(), getchar().
+~ Implement more of <stdio.h>:
+ ~ <stdio.h>: feof(), fgetc(), getc(), getchar().
- Implement more of <stdlib.h>:
~ <stdlib.h>: _Exit(), exit(), atexit().
~ <stdlib.h>: quick_exit(), at_quick_exit().
View
@@ -71,6 +71,11 @@ int ferror(FILE* stream);
*/
int fflush(FILE* stream);
+/**
+ * C11 7.21.7.1
+ */
+int fgetc(FILE* stream);
+
/**
* C11 7.21.7.3
*/
@@ -81,6 +86,16 @@ int fputc(int chr, FILE* stream);
*/
int fputs(const char* restrict str, FILE* restrict stream);
+/**
+ * C11 7.21.7.5
+ */
+int getc(FILE* stream);
+
+/**
+ * C11 7.21.7.6
+ */
+int getchar(void);
+
/**
* C11 7.21.10.4
*/
View
@@ -3,10 +3,14 @@ noinst_LTLIBRARIES = libcstdio.la
libcstdio_la_SOURCES = \
clearerr.c \
fclose.c \
+ feof.c \
ferror.c \
fflush.c \
+ fgetc.c \
fputc.c \
fputs.c \
+ getc.c \
+ getchar.c \
putc.c \
putchar.c \
puts.c \
View
@@ -0,0 +1,20 @@
+/* This is free and unencumbered software released into the public domain. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h> /* for FILE, feof() */
+
+#include "sysio.h" /* for __sysio_*() */
+
+/**
+ * @date 2014-11-23
+ * @author Arto Bendiken
+ * @see http://libc11.org/stdio/feof.html
+ */
+int
+feof(FILE* const stream) {
+
+ return *__sysio_errno(stream); // FIXME
+}
View
@@ -0,0 +1,18 @@
+/* This is free and unencumbered software released into the public domain. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h> /* for EOF, FILE, fgetc() */
+
+/**
+ * @date 2014-11-23
+ * @author Arto Bendiken
+ * @see http://libc11.org/stdio/fgetc.html
+ */
+int
+fgetc(FILE* const stream) {
+
+ return (void)stream, EOF; // TODO
+}
View
@@ -0,0 +1,18 @@
+/* This is free and unencumbered software released into the public domain. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h> /* for FILE, fgetc(), getc() */
+
+/**
+ * @date 2014-11-23
+ * @author Arto Bendiken
+ * @see http://libc11.org/stdio/getc.html
+ */
+int
+getc(FILE* const stream) {
+
+ return fgetc(stream);
+}
View
@@ -0,0 +1,18 @@
+/* This is free and unencumbered software released into the public domain. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h> /* for stdin, fgetc(), getchar() */
+
+/**
+ * @date 2014-11-23
+ * @author Arto Bendiken
+ * @see http://libc11.org/stdio/getchar.html
+ */
+int
+getchar(void) {
+
+ return fgetc(stdin);
+}

0 comments on commit 1fb46d0

Please sign in to comment.