Skip to content
This repository has been archived by the owner on Jan 11, 2020. It is now read-only.

Commit

Permalink
Stubbed the <stdio.h> feof(), fgetc(), getc(), getchar() functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
artob committed Nov 23, 2014
1 parent f6e8f37 commit 1fb46d0
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 2 deletions.
4 changes: 2 additions & 2 deletions TODO
Expand Up @@ -6,8 +6,8 @@ Release 0.1.0 ("Hello, world!")
- <signal.h>: raise(). - <signal.h>: raise().
~ <stdlib.h>: abort(). ~ <stdlib.h>: abort().
- <assert.h>: assert(). - <assert.h>: assert().
- Implement more of <stdio.h>: ~ Implement more of <stdio.h>:
- <stdio.h>: feof(), fgetc(), getc(), getchar(). ~ <stdio.h>: feof(), fgetc(), getc(), getchar().
- Implement more of <stdlib.h>: - Implement more of <stdlib.h>:
~ <stdlib.h>: _Exit(), exit(), atexit(). ~ <stdlib.h>: _Exit(), exit(), atexit().
~ <stdlib.h>: quick_exit(), at_quick_exit(). ~ <stdlib.h>: quick_exit(), at_quick_exit().
Expand Down
15 changes: 15 additions & 0 deletions src/include/stdio.h
Expand Up @@ -71,6 +71,11 @@ int ferror(FILE* stream);
*/ */
int fflush(FILE* stream); int fflush(FILE* stream);


/**
* C11 7.21.7.1
*/
int fgetc(FILE* stream);

/** /**
* C11 7.21.7.3 * C11 7.21.7.3
*/ */
Expand All @@ -81,6 +86,16 @@ int fputc(int chr, FILE* stream);
*/ */
int fputs(const char* restrict str, FILE* restrict 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 * C11 7.21.10.4
*/ */
Expand Down
4 changes: 4 additions & 0 deletions src/stdio/Makefile.am
Expand Up @@ -3,10 +3,14 @@ noinst_LTLIBRARIES = libcstdio.la
libcstdio_la_SOURCES = \ libcstdio_la_SOURCES = \
clearerr.c \ clearerr.c \
fclose.c \ fclose.c \
feof.c \
ferror.c \ ferror.c \
fflush.c \ fflush.c \
fgetc.c \
fputc.c \ fputc.c \
fputs.c \ fputs.c \
getc.c \
getchar.c \
putc.c \ putc.c \
putchar.c \ putchar.c \
puts.c \ puts.c \
Expand Down
20 changes: 20 additions & 0 deletions src/stdio/feof.c
@@ -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
}
18 changes: 18 additions & 0 deletions src/stdio/fgetc.c
@@ -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
}
18 changes: 18 additions & 0 deletions src/stdio/getc.c
@@ -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);
}
18 changes: 18 additions & 0 deletions src/stdio/getchar.c
@@ -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.