diff options
author | Alex Auvolat <alex@adnab.me> | 2017-04-21 16:57:00 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2017-04-21 16:57:00 +0200 |
commit | f8334e283c5eb0efeb4bb8a134041e18388d5f01 (patch) | |
tree | 508bc475133262afee1d4a1d9fe7af3f576e2ee9 /src/lib/libc | |
parent | ec08d0410730a16836eb40f5e46082b3bbaf45f6 (diff) | |
download | kogata-f8334e283c5eb0efeb4bb8a134041e18388d5f01.tar.gz kogata-f8334e283c5eb0efeb4bb8a134041e18388d5f01.zip |
Lua init
Diffstat (limited to 'src/lib/libc')
-rw-r--r-- | src/lib/libc/stdio.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/libc/stdio.c b/src/lib/libc/stdio.c index 864fb34..bfa2f74 100644 --- a/src/lib/libc/stdio.c +++ b/src/lib/libc/stdio.c @@ -225,6 +225,10 @@ size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) { } int fgetc(FILE *stream) { + if (stream == NULL) { + return EOF; + } + dbg_printf("FGETC %p\n", stream); // TODO buffering && ungetc @@ -321,10 +325,10 @@ int setvbuf(FILE *stream, char *buf, int mode, size_t size) { int fflush(FILE* stream) { dbg_printf("FFLUSH %p\n", stream); - if (!(stream->file_mode & FM_WRITE)) return 0; if (stream == NULL || stream->fd == 0) { return EOF; } + if (!(stream->file_mode & FM_WRITE)) return 0; if (stream->buf_mode != 0 && stream->out_buf_used > 0) { size_t ret = sc_write(stream->fd, stream->pos, stream->out_buf_used, stream->out_buf); |