From ecd4d00f1bdf184163cc44ed8261d9f11ca9aae0 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Wed, 12 Aug 2020 11:02:56 -0400 Subject: remove all generated nonstd/ headers --- src/stdio/__stdio.c | 5 +++++ src/stdio/feof.c | 2 +- src/stdio/ferror.c | 2 +- src/stdio/fileno.c | 2 +- src/stdio/popen.c | 2 +- src/stdio/setvbuf.c | 12 ++++++++++-- 6 files changed, 19 insertions(+), 6 deletions(-) (limited to 'src/stdio') diff --git a/src/stdio/__stdio.c b/src/stdio/__stdio.c index d607bde6..2360020f 100644 --- a/src/stdio/__stdio.c +++ b/src/stdio/__stdio.c @@ -1,2 +1,7 @@ #include "_stdio.h" + struct __stdio __stdio; + +/* +STDC(0) +*/ diff --git a/src/stdio/feof.c b/src/stdio/feof.c index 9524d8c6..8b2455bd 100644 --- a/src/stdio/feof.c +++ b/src/stdio/feof.c @@ -1,6 +1,6 @@ #include #include "_stdio.h" -#include "nonstd/assert.h" +#include "../_assert.h" /** test for end-of-file **/ int feof(FILE *stream) diff --git a/src/stdio/ferror.c b/src/stdio/ferror.c index 9d427e1f..d4e014d4 100644 --- a/src/stdio/ferror.c +++ b/src/stdio/ferror.c @@ -1,5 +1,5 @@ #include -#include "nonstd/assert.h" +#include "../_assert.h" #include "_stdio.h" /** tests the file stream error indicator **/ diff --git a/src/stdio/fileno.c b/src/stdio/fileno.c index 8292001d..969f572c 100644 --- a/src/stdio/fileno.c +++ b/src/stdio/fileno.c @@ -1,6 +1,6 @@ #include #include "_stdio.h" -#include "nonstd/assert.h" +#include "../_assert.h" int fileno(FILE * stream) { diff --git a/src/stdio/popen.c b/src/stdio/popen.c index 04918003..0e0fc663 100644 --- a/src/stdio/popen.c +++ b/src/stdio/popen.c @@ -5,7 +5,7 @@ #include "sys/types.h" #include "unistd.h" -#include "nonstd/assert.h" +#include "../_assert.h" #include "_stdio.h" #ifdef __STDC_VERSION__ diff --git a/src/stdio/setvbuf.c b/src/stdio/setvbuf.c index e5800288..ecf038fd 100644 --- a/src/stdio/setvbuf.c +++ b/src/stdio/setvbuf.c @@ -16,11 +16,19 @@ int setvbuf(FILE *stream, char *buf, int mode, size_t size) stream->buffering = mode; stream->bsize = size; + if (mode == _IONBF) { + /* maybe free buffer */ + return 0; + } + if (buf != NULL) { stream->buf = buf; stream->buftype = SUPPLIED; - } else if (mode != _IONBF) { - stream->buf = calloc(size, sizeof(char)); + } else if (size <= BUFSIZ) { + stream->buf = stream->ibuf; + stream->buftype = INTERNAL; + } else { + stream->buf = malloc(size); stream->buftype = ALLOCED; } -- cgit v1.2.1