diff options
author | Jakob Kaivo <jkk@ung.org> | 2024-01-30 14:25:31 -0500 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2024-01-30 14:25:31 -0500 |
commit | 000a7c045c98c30aac86db93f8c9c978e5ca8c59 (patch) | |
tree | f882b1258d0c9b32f8517a9557b86e6ebc8aa9bb | |
parent | b25685d5dc26370ecae112f805b4141c4efdeea4 (diff) |
update standards and safety checks
85 files changed, 232 insertions, 448 deletions
diff --git a/src/stdio/__printf.c b/src/stdio/__printf.c index c918cac5..0d950583 100644 --- a/src/stdio/__printf.c +++ b/src/stdio/__printf.c @@ -1,13 +1,11 @@ -#if 0 - -#include <sys/types.h> +//#include <sys/types.h> #include <stdio.h> #include <stddef.h> #include "wctype/wint_t.h" #include "wctype/wctrans_t.h" #include <wchar.h> #include <inttypes.h> -#include <unistd.h> +//#include <unistd.h> #include <stdlib.h> #include "_stdio.h" @@ -345,5 +343,7 @@ int (__printf)(struct io_options *opt, const char * format, va_list arg) return nout; } - -#endif +/* +STDC(0) +SIGNAL_SAFE(0) +*/ diff --git a/src/stdio/__scanf.c b/src/stdio/__scanf.c index 7451ad4a..ed837b44 100644 --- a/src/stdio/__scanf.c +++ b/src/stdio/__scanf.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdarg.h> #include <stdio.h> #include "_stdio.h" @@ -12,5 +10,7 @@ int __scanf(struct io_options *opt, const char * format, va_list arg) return 0; } - -#endif +/* +STDC(0) +SIGNAL_SAFE(0) +*/ diff --git a/src/stdio/__stderr.c b/src/stdio/__stderr.c index 681398aa..654eb4c0 100644 --- a/src/stdio/__stderr.c +++ b/src/stdio/__stderr.c @@ -1,7 +1,7 @@ -#if 0 - #include <stdio.h> FILE *__stderr; - -#endif +/* +STDC(0) +SIGNAL_SAFE(0) +*/ diff --git a/src/stdio/__stdin.c b/src/stdio/__stdin.c index 08b6fd5d..57741fa3 100644 --- a/src/stdio/__stdin.c +++ b/src/stdio/__stdin.c @@ -1,7 +1,7 @@ -#if 0 - #include <stdio.h> FILE *__stdin; - -#endif +/* +STDC(0) +SIGNAL_SAFE(0) +*/ diff --git a/src/stdio/__stdio.c b/src/stdio/__stdio.c index 26f57b61..d77e01dc 100644 --- a/src/stdio/__stdio.c +++ b/src/stdio/__stdio.c @@ -1,8 +1,8 @@ -#if 0 - #include "_stdio.h" struct __stdio __stdio = { 0 }; - -#endif +/* +STDC(0) +SIGNAL_SAFE(0) +*/ diff --git a/src/stdio/__stdout.c b/src/stdio/__stdout.c index 8cf18d91..bf4270b6 100644 --- a/src/stdio/__stdout.c +++ b/src/stdio/__stdout.c @@ -1,7 +1,7 @@ -#if 0 - #include <stdio.h> FILE *__stdout; - -#endif +/* +STDC(0) +SIGNAL_SAFE(0) +*/ diff --git a/src/stdio/_stdio.h b/src/stdio/_stdio.h index 80b83556..43d8841b 100644 --- a/src/stdio/_stdio.h +++ b/src/stdio/_stdio.h @@ -4,6 +4,7 @@ #include <stddef.h> #include <stdarg.h> #include <stdio.h> +#include "_safety.h" #ifdef _POSIX_C_SOURCE #include <sys/types.h> diff --git a/src/stdio/clearerr.c b/src/stdio/clearerr.c index a3196a71..f7d2aac1 100644 --- a/src/stdio/clearerr.c +++ b/src/stdio/clearerr.c @@ -1,12 +1,12 @@ -#if 0 - #include <stdio.h> #include "_stdio.h" +#include "_safety.h" /** reset file stream error indicator **/ void clearerr(FILE * stream) { + SIGNAL_SAFE(0); flockfile(stream); if (stream != NULL) { stream->eof = 0; @@ -22,6 +22,3 @@ clears the error and end-of-file indicators of ARGUMENT(stream). /* STDC(1) */ - - -#endif diff --git a/src/stdio/fclose.c b/src/stdio/fclose.c index 8649c718..f438a9c2 100644 --- a/src/stdio/fclose.c +++ b/src/stdio/fclose.c @@ -1,15 +1,17 @@ -#if 0 - #ifndef _POSIX_SOURCE #define _POSIX_SOURCE #define POSIX_FORCED #endif + #include <stdio.h> #include <stdlib.h> #include <string.h> +#if 0 #include <sys/types.h> #include <unistd.h> +#endif + #include "_stdio.h" #ifdef POSIX_FORCED @@ -21,6 +23,8 @@ int fclose(FILE *stream) { + SIGNAL_SAFE(0); + flockfile(stream); if (fflush(stream) == EOF) { /* set errno */ @@ -58,6 +62,3 @@ buffer was automatically allocated, it is freed. /* STDC(1) */ - - -#endif diff --git a/src/stdio/fdopen.c b/src/stdio/fdopen.c index 12bb1a10..875d5b9a 100644 --- a/src/stdio/fdopen.c +++ b/src/stdio/fdopen.c @@ -1,15 +1,13 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" FILE * fdopen(int fildes, const char * mode) { + SIGNAL_SAFE(0); (void)fildes; (void)mode; return NULL; } + /* POSIX(1) */ - - -#endif diff --git a/src/stdio/feof.c b/src/stdio/feof.c index 8e00489c..39d9b645 100644 --- a/src/stdio/feof.c +++ b/src/stdio/feof.c @@ -1,13 +1,11 @@ -#if 0 - #include <stdio.h> -#include "_assert.h" #include "_stdio.h" /** test for end-of-file **/ int feof(FILE *stream) { + SIGNAL_SAFE(0); ASSERT_NONNULL(stream); flockfile(stream); @@ -31,6 +29,3 @@ tests for the end-of-file indicator of ARGUMENT(stream). /* STDC(1) */ - - -#endif diff --git a/src/stdio/ferror.c b/src/stdio/ferror.c index fb6adf0d..66299ab9 100644 --- a/src/stdio/ferror.c +++ b/src/stdio/ferror.c @@ -1,13 +1,11 @@ -#if 0 - #include <stdio.h> -#include "_assert.h" #include "_stdio.h" /** tests the file stream error indicator **/ int ferror(FILE *stream) { + SIGNAL_SAFE(0); ASSERT_NONNULL(stream); /* RETURN(0, the error indicator is not set); @@ -23,6 +21,3 @@ tests the error indicator of ARGUMENT(stream). /* STDC(1) */ - - -#endif diff --git a/src/stdio/fflush.c b/src/stdio/fflush.c index 8adb0a10..23899e82 100644 --- a/src/stdio/fflush.c +++ b/src/stdio/fflush.c @@ -1,13 +1,11 @@ -#if 0 - #ifndef _POSIX_SOURCE #define _POSIX_SOURCE #define POSIX_FORCED #endif #include <stdio.h> -#include <sys/types.h> -#include <unistd.h> +//#include <sys/types.h> +//#include <unistd.h> #include "_stdio.h" #ifdef POSIX_FORCED @@ -21,6 +19,8 @@ int fflush(FILE *stream) { int ret = 0; + SIGNAL_SAFE(0); + if (stream == NULL) { size_t i; for (i = 0; i < FOPEN_MAX; i++) { @@ -63,6 +63,3 @@ UNDEFINED(ARGUMENT(stream) is not an output stream) UNDEFINED(ARGUMENT(stream) is an update stream in which the most recent operation was input) STDC(1) */ - - -#endif diff --git a/src/stdio/fgetc.c b/src/stdio/fgetc.c index b3dde1bd..06e4c064 100644 --- a/src/stdio/fgetc.c +++ b/src/stdio/fgetc.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdio.h> #include "_stdio.h" @@ -13,6 +11,7 @@ int fgetc(FILE *stream) { + SIGNAL_SAFE(0); flockfile(stream); char c = getc_unlocked(stream); funlockfile(stream); @@ -34,6 +33,3 @@ of ARGUMENT(stream) is advanced. /* STDC(1) */ - - -#endif diff --git a/src/stdio/fgetpos.c b/src/stdio/fgetpos.c index b0b25161..65b35cf7 100644 --- a/src/stdio/fgetpos.c +++ b/src/stdio/fgetpos.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdio.h> #include "_stdio.h" @@ -7,6 +5,8 @@ int fgetpos(FILE * restrict stream, fpos_t * restrict pos) { + SIGNAL_SAFE(0); + flockfile(stream); *pos = stream->pos; funlockfile(stream); @@ -22,6 +22,3 @@ for ARGUMENT(stream) into the TYPEDEF(fpos_t) at ARGUMENT(pos). UNSPECIFIED(The information stored in TYPEDEF(fpos_t)) STDC(1) */ - - -#endif diff --git a/src/stdio/fgets.c b/src/stdio/fgets.c index 8606fdea..8e7bf449 100644 --- a/src/stdio/fgets.c +++ b/src/stdio/fgets.c @@ -1,13 +1,14 @@ -#if 0 - #include <stdio.h> #include "_stdio.h" +#undef fgets /** read a string of characters from a file stream **/ char * fgets(char * restrict s, int n, FILE * restrict stream) { int i = 0; + SIGNAL_SAFE(0); + if (feof(stream)) { return NULL; } @@ -55,6 +56,3 @@ If an error occurs, the contents of ARGUMENT(s) are indeterminite. /* STDC(1) */ - - -#endif diff --git a/src/stdio/fileno.c b/src/stdio/fileno.c index 7a6cbd7c..5432ecb0 100644 --- a/src/stdio/fileno.c +++ b/src/stdio/fileno.c @@ -1,17 +1,13 @@ -#if 0 - #include <stdio.h> #include "_stdio.h" -#include "_assert.h" int fileno(FILE * stream) { + SIGNAL_SAFE(0); ASSERT_NONNULL(stream); return stream->fd; } + /* POSIX(1) */ - - -#endif diff --git a/src/stdio/flockfile.c b/src/stdio/flockfile.c index 8b3efee5..62397e74 100644 --- a/src/stdio/flockfile.c +++ b/src/stdio/flockfile.c @@ -1,14 +1,12 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" void flockfile(FILE * file) { + SIGNAL_SAFE(0); + ASSERT_NONNULL(file); } /* POSIX(199506) */ - - -#endif diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c index d20015ca..b62491bc 100644 --- a/src/stdio/fopen.c +++ b/src/stdio/fopen.c @@ -1,9 +1,8 @@ -#if 0 - #include <errno.h> #include <stdio.h> #include <stdlib.h> #include "_stdio.h" +#undef fopen /** open a file stream **/ @@ -12,6 +11,8 @@ FILE * fopen(const char * restrict filename, const char * restrict mode) FILE *f = NULL; size_t i; + SIGNAL_SAFE(0); + for (i = 0; i < FOPEN_MAX; i++) { if (__stdio.FILES[i].bmode == 0) { f = &(__stdio.FILES[i]); @@ -65,6 +66,3 @@ The error and end-of-file indicators are cleared. /* STDC(1) */ - - -#endif diff --git a/src/stdio/fopen_s.c b/src/stdio/fopen_s.c index 708a1fc2..411f6bbf 100644 --- a/src/stdio/fopen_s.c +++ b/src/stdio/fopen_s.c @@ -1,18 +1,15 @@ -#if 0 - #include <stdio.h> -#include "__stdio.h" +#include "_stdio.h" #include <string.h> #include <stdlib.h> -#include <fcntl.h> -#include <unistd.h> /** open a file stream **/ errno_t fopen_s(FILE * restrict * restrict streamptr, const char * restrict filename, - const char * restrict mode); + const char * restrict mode) { - __C_EXT(1, 201112L); + SIGNAL_SAFE(0); + (void)streamptr; (void)filename; (void)mode; return 0; } @@ -55,6 +52,3 @@ The error and end-of-file indicators are cleared. /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/fprintf.c b/src/stdio/fprintf.c index 668843e0..72bca8c4 100644 --- a/src/stdio/fprintf.c +++ b/src/stdio/fprintf.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdarg.h> #include <stdio.h> #include "_stdio.h" @@ -11,6 +9,9 @@ int fprintf(FILE * restrict stream, const char * restrict format, ...) int ret = 0; va_list ap; struct io_options opt = {0}; + + SIGNAL_SAFE(0); + opt.fnname = "fprintf"; opt.stream = stream; va_start(ap, format); @@ -31,6 +32,3 @@ and the variadic arguments is the same as that for FUNCTION(printf). /* STDC(1) */ - - -#endif diff --git a/src/stdio/fprintf_s.c b/src/stdio/fprintf_s.c index 1c50f26d..2e5ed670 100644 --- a/src/stdio/fprintf_s.c +++ b/src/stdio/fprintf_s.c @@ -1,12 +1,11 @@ -#if 0 - #include <stdio.h> #include <stdarg.h> +#include "_stdio.h" /** write formatted output to a file stream **/ int fprintf_s(FILE * restrict stream, const char * restrict format, ...) { - __C_EXT(1, 201112L); + SIGNAL_SAFE(0); int retval; va_list ap; va_start(ap, format); @@ -31,6 +30,3 @@ of arg(format) and the variadic arguments is the same as that for fn(printf). /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/fputc.c b/src/stdio/fputc.c index b551541d..1a17ba32 100644 --- a/src/stdio/fputc.c +++ b/src/stdio/fputc.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdio.h> #include "_stdio.h" @@ -11,9 +9,10 @@ /** write a character to a file stream **/ -int fputc(int c, FILE *stream) +int (fputc)(int c, FILE *stream) { int ret = EOF; + SIGNAL_SAFE(0); flockfile(stream); ret = putc_unlocked(c, stream); funlockfile(stream); @@ -35,6 +34,3 @@ RETURN_SUCCESS(ARGUMENT(c)) RETURN_FAILURE(CONSTANT(EOF)) STDC(1) */ - - -#endif diff --git a/src/stdio/fputs.c b/src/stdio/fputs.c index 9d6a9c90..a82338d1 100644 --- a/src/stdio/fputs.c +++ b/src/stdio/fputs.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdio.h> #include "_stdio.h" @@ -7,6 +5,7 @@ int fputs(const char * restrict s, FILE * restrict stream) { + SIGNAL_SAFE(0); flockfile(stream); while (*s) { if (fputc(*s++, stream) == EOF) { @@ -30,6 +29,3 @@ the terminating CHAR(\0) character. /* STDC(1) */ - - -#endif diff --git a/src/stdio/fread.c b/src/stdio/fread.c index b1b077dd..5b7f38b4 100644 --- a/src/stdio/fread.c +++ b/src/stdio/fread.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdio.h> #include "_stdio.h" @@ -9,6 +7,9 @@ size_t fread(void * restrict ptr, size_t size, size_t nmemb, FILE * restrict str { unsigned char *buf = ptr; size_t n = 0; + + SIGNAL_SAFE(0); + flockfile(stream); while (nmemb) { size_t i; @@ -41,6 +42,3 @@ The file position indicate is advanced by the number of bytes read. /* STDC(1) */ - - -#endif diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c index cee31692..b39fda4c 100644 --- a/src/stdio/freopen.c +++ b/src/stdio/freopen.c @@ -1,16 +1,14 @@ -#if 0 - #ifndef _POSIX_SOURCE #define _POSIX_SOURCE #define POSIX_FORCED #endif -#include <sys/types.h> +//#include <sys/types.h> #include <errno.h> -#include <fcntl.h> +//#include <fcntl.h> #include <stdio.h> #include <string.h> -#include <unistd.h> +//#include <unistd.h> #include "_stdio.h" #ifdef POSIX_FORCED @@ -18,6 +16,12 @@ #include "_syscall.h" #define open(_p, _f, _m) __scall3(open, _p, _f, _m) #define isatty(_fd) ioctl(_fd, TCFLSH, 0) +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_CREAT 0100 +#define O_TRUNC 01000 +#define O_APPEND 02000 +#define O_RDWR 02 #endif /** reopen a file stream with a new file **/ @@ -53,6 +57,8 @@ FILE * freopen(const char * restrict filename, const char * restrict mode, FILE size_t i; int fd = -1; + SIGNAL_SAFE(0); + for (i = 0; i < sizeof(modemap) / sizeof(modemap[0]); i++) { if (!strcmp(modemap[i].smode, mode)) { openmode = modemap[i].omode; @@ -108,6 +114,3 @@ The error and end-of-file indicators are cleared. /* STDC(1) */ - - -#endif diff --git a/src/stdio/freopen_s.c b/src/stdio/freopen_s.c index e49c7cf1..c5105b13 100644 --- a/src/stdio/freopen_s.c +++ b/src/stdio/freopen_s.c @@ -1,8 +1,5 @@ -#if 0 - #include <stdio.h> -#include "__stdio.h" -#include <fcntl.h> +#include "_stdio.h" #include <string.h> /** reopen a file stream with a new file **/ @@ -11,7 +8,8 @@ errno_t freopen_s(FILE * restrict * restrict newstreamptr, const char * restrict mode, FILE * restrict stream) { - __C_EXT(1, 201112L); + SIGNAL_SAFE(0); + (void)newstreamptr; (void)filename; (void)mode; (void)stream; return 0; } @@ -36,6 +34,3 @@ The error and end-of-file indicators are cleared. /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/fscanf.c b/src/stdio/fscanf.c index 17d0c038..98dbeed1 100644 --- a/src/stdio/fscanf.c +++ b/src/stdio/fscanf.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdarg.h> #include <stdio.h> #include "_stdio.h" @@ -11,6 +9,9 @@ int fscanf(FILE * restrict stream, const char * restrict format, ...) int ret = 0; va_list ap; struct io_options opt = {0}; + + SIGNAL_SAFE(0); + opt.fnname = "fscanf"; opt.stream = stream; va_start(ap, format); @@ -31,6 +32,3 @@ the variadic arguments is the same as that for FUNCTION(scanf). /* STDC(1) */ - - -#endif diff --git a/src/stdio/fscanf_s.c b/src/stdio/fscanf_s.c index 77ca35d0..4d01ba5e 100644 --- a/src/stdio/fscanf_s.c +++ b/src/stdio/fscanf_s.c @@ -1,11 +1,11 @@ -#if 0 - #include <stdio.h> #include <stdarg.h> +#include "_stdio.h" /** read formatted input from a file stream **/ int fscanf_s(FILE * restrict stream, const char * restrict format, ...) { + SIGNAL_SAFE(0); va_list ap; va_start(ap, format); int ret = vfscanf_s(stream, format, ap); @@ -29,6 +29,3 @@ arg(format) at the variadic arguments is the same as that for fn(scanf). /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/fseek.c b/src/stdio/fseek.c index fb40fa70..e1c6db57 100644 --- a/src/stdio/fseek.c +++ b/src/stdio/fseek.c @@ -1,11 +1,12 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" /** set the file position indicator **/ int fseek(FILE *stream, long int offset, int whence) { + SIGNAL_SAFE(0); + (void)stream; (void)offset; if (whence == SEEK_CUR) { @@ -34,6 +35,3 @@ UNDEFINED(Specifying CONSTANT(SEEK_END) for ARGUMENT(whence) on a binary file) UNDEFINED(Specifying a value for ARGUMENT(offset) other than 0 or a previous return value of FUNCTION(ftell) on a text file) STDC(1) */ - - -#endif diff --git a/src/stdio/fsetpos.c b/src/stdio/fsetpos.c index f56aef48..ca6cb806 100644 --- a/src/stdio/fsetpos.c +++ b/src/stdio/fsetpos.c @@ -1,11 +1,11 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" /** set the file position indicator **/ int fsetpos(FILE *stream, const fpos_t *pos) { + SIGNAL_SAFE(0); (void)stream; (void)pos; /* TODO */ return 1; @@ -23,6 +23,3 @@ any characters pushed back with FUNCTION(ungetc). /* STDC(1) */ - - -#endif diff --git a/src/stdio/ftell.c b/src/stdio/ftell.c index 521af102..f68c18b2 100644 --- a/src/stdio/ftell.c +++ b/src/stdio/ftell.c @@ -1,11 +1,12 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" /** get the file position indicator **/ long int ftell(FILE *stream) { + SIGNAL_SAFE(0); + (void)stream; /* TODO */ /* @@ -25,6 +26,3 @@ For binary streams, the indicator is the current byte position. UNSPECIFIED(The meaning of the file position indicator for text streams) STDC(1) */ - - -#endif diff --git a/src/stdio/funlockfile.c b/src/stdio/funlockfile.c index 76780b37..978aded2 100644 --- a/src/stdio/funlockfile.c +++ b/src/stdio/funlockfile.c @@ -1,14 +1,11 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" void funlockfile(FILE * file) { + SIGNAL_SAFE(0); } /* POSIX(199506) */ - - -#endif diff --git a/src/stdio/fwrite.c b/src/stdio/fwrite.c index 724e0c29..52861b00 100644 --- a/src/stdio/fwrite.c +++ b/src/stdio/fwrite.c @@ -1,6 +1,5 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" /** write directly to a file stream **/ @@ -8,6 +7,8 @@ size_t fwrite(const void * restrict ptr, size_t size, size_t nmemb, FILE * restr { unsigned char *buf = (unsigned char *)ptr; size_t n = 0; + SIGNAL_SAFE(0); + while (nmemb) { size_t i; for (i = 0; i < size; i++) { @@ -38,6 +39,3 @@ written. /* STDC(1) */ - - -#endif diff --git a/src/stdio/getc.c b/src/stdio/getc.c index b4b8c854..4cb6290c 100644 --- a/src/stdio/getc.c +++ b/src/stdio/getc.c @@ -1,11 +1,11 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" /** read a character from a file stream **/ int getc(FILE *stream) { + SIGNAL_SAFE(0); /* RETURN_SUCCESS(the next character); RETURN_FAILURE(CONSTANT(EOF)); @@ -21,6 +21,3 @@ defined as a macro, it may evaluate ARGUMENT(stream) more than once. /* STDC(1) */ - - -#endif diff --git a/src/stdio/getc_unlocked.c b/src/stdio/getc_unlocked.c index 038e2cf0..140e1a4d 100644 --- a/src/stdio/getc_unlocked.c +++ b/src/stdio/getc_unlocked.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdio.h> #include "_stdio.h" @@ -15,6 +13,8 @@ int getc_unlocked(FILE * stream) { char c = 0; + SIGNAL_SAFE(0); + if (!stream) { return EOF; } @@ -30,6 +30,3 @@ int getc_unlocked(FILE * stream) /* POSIX(199506) */ - - -#endif diff --git a/src/stdio/getchar.c b/src/stdio/getchar.c index 2d229847..faee8889 100644 --- a/src/stdio/getchar.c +++ b/src/stdio/getchar.c @@ -1,11 +1,12 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" +#undef getchar /** read a character from stdin **/ int getchar(void) { + SIGNAL_SAFE(0); /* RETURN_SUCCESS(the next character); RETURN_FAILURE(CONSTANT(EOF)); @@ -20,6 +21,3 @@ reads the next character from ARGUMENT(stdin). /* STDC(1) */ - - -#endif diff --git a/src/stdio/getchar_unlocked.c b/src/stdio/getchar_unlocked.c index 886d5016..c62ffbf0 100644 --- a/src/stdio/getchar_unlocked.c +++ b/src/stdio/getchar_unlocked.c @@ -1,15 +1,11 @@ -#if 0 - #include <stdio.h> int getchar_unlocked(void) { + SIGNAL_SAFE(0); return getc_unlocked(stdin); } /* POSIX(199506) */ - - -#endif diff --git a/src/stdio/gets.c b/src/stdio/gets.c index 261417c7..21ef3597 100644 --- a/src/stdio/gets.c +++ b/src/stdio/gets.c @@ -1,12 +1,12 @@ -#if 0 - #include <stdio.h> #include <limits.h> +#include "_stdio.h" /** read a line from stdin **/ char * gets(char *s) { + SIGNAL_SAFE(0); /* RETURN_SUCCESS(ARGUMENT(s)); RETURN_FAILURE(CONSTANT(NULL)); @@ -30,6 +30,3 @@ remain unchanged. /* STDC(1,201112) */ - - -#endif diff --git a/src/stdio/gets_s.c b/src/stdio/gets_s.c index 3cbe4d86..f6b453aa 100644 --- a/src/stdio/gets_s.c +++ b/src/stdio/gets_s.c @@ -1,12 +1,12 @@ -#if 0 - #include <stdio.h> #include <limits.h> +#include "_stdio.h" /** read a line from stdin **/ char * gets_s(char *s, rsize_t n) { - __C_EXT(1, 201112L); + SIGNAL_SAFE(0); + (void)n; return fgets(s, INT_MAX, stdin); } @@ -33,6 +33,3 @@ remain unchanged. /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/getw.c b/src/stdio/getw.c index 6476781c..ad1b0bad 100644 --- a/src/stdio/getw.c +++ b/src/stdio/getw.c @@ -1,17 +1,14 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" # define _XOPEN_LEGACY 500 int getw(FILE *stream) { + SIGNAL_SAFE(0); return 0; } /* XOPEN(4,600) */ - - -#endif diff --git a/src/stdio/pclose.c b/src/stdio/pclose.c index 1d7a5b19..b39cfa15 100644 --- a/src/stdio/pclose.c +++ b/src/stdio/pclose.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdio.h> #include <sys/types.h> #include <sys/wait.h> @@ -9,6 +7,8 @@ int pclose(FILE * stream) { int status; pid_t child = stream->pipe_pid; + SIGNAL_SAFE(0); + if (child == 0) { /* undefined behavior */ } @@ -22,7 +22,3 @@ int pclose(FILE * stream) /* POSIX(2) */ - - - -#endif diff --git a/src/stdio/perror.c b/src/stdio/perror.c index 8053a5dc..88e582de 100644 --- a/src/stdio/perror.c +++ b/src/stdio/perror.c @@ -1,13 +1,14 @@ -#if 0 - #include <errno.h> #include <stdio.h> #include <string.h> +#include "_stdio.h" /** print an error message **/ void perror(const char *s) { + SIGNAL_SAFE(0); + if (s != NULL && *s != '\0') { fprintf(stderr, "%s: ", s); } @@ -28,6 +29,3 @@ pointed to by ARGUMENT(s), a colon (CHAR(:)), and a space. POSIX_(L_C_MESSAGES) STDC(1) */ - - -#endif diff --git a/src/stdio/popen.c b/src/stdio/popen.c index 550c8fda..67b70f4d 100644 --- a/src/stdio/popen.c +++ b/src/stdio/popen.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdio.h> #include <string.h> #include <errno.h> @@ -7,7 +5,6 @@ #include <sys/types.h> #include <unistd.h" -#include "_assert.h" #include "_stdio.h" #ifdef __STDC_VERSION__ @@ -16,6 +13,7 @@ FILE * popen(const char * command, const char * mode) { + SIGNAL_SAFE(0); ASSERT_NONNULL(command); ASSERT_NONNULL(mode); @@ -71,7 +69,3 @@ FILE * popen(const char * command, const char * mode) /* POSIX(2) */ - - - -#endif diff --git a/src/stdio/printf.c b/src/stdio/printf.c index f28240f4..6f8746c8 100644 --- a/src/stdio/printf.c +++ b/src/stdio/printf.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdarg.h> #include <stdio.h> #include "_stdio.h" @@ -11,6 +9,9 @@ int printf(const char *format, ...) int ret = 0; va_list ap; struct io_options opt = {0}; + + SIGNAL_SAFE(0); + opt.fnname = "printf"; opt.stream = stdout; va_start(ap, format); @@ -108,6 +109,3 @@ UNDEFINED(`Precision with a conversion specifier other than CHAR(d), CHAR(i), CH UNDEFINED(TODO: Using h or l for !(diouxXn) or L for !(eEfgG)) STDC(1) */ - - -#endif diff --git a/src/stdio/printf_s.c b/src/stdio/printf_s.c index 408c9d72..92b4ca7c 100644 --- a/src/stdio/printf_s.c +++ b/src/stdio/printf_s.c @@ -1,11 +1,11 @@ -#if 0 - #include <stdio.h> #include <stdarg.h> +#include "_stdio.h" /** write formatted output **/ int printf_s(const char *format, ...) { + SIGNAL_SAFE(0); va_list ap; va_start(ap, format); int ret = vfprintf_s(stdout, format, ap); @@ -30,6 +30,3 @@ FIXME: printf format goes here /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/putc.c b/src/stdio/putc.c index 5a0836dd..8dc2024f 100644 --- a/src/stdio/putc.c +++ b/src/stdio/putc.c @@ -1,11 +1,11 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" /** write a character to a file stream **/ int putc(int c, FILE *stream) { + SIGNAL_SAFE(0); /* RETURN_SUCCESS(ARGUMENT(c)); RETURN_FAILURE(CONSTANT(EOF)); @@ -21,6 +21,3 @@ as a macro, it may evaluate ARGUMENT(stream) more than once. /* STDC(1) */ - - -#endif diff --git a/src/stdio/putc_unlocked.c b/src/stdio/putc_unlocked.c index 4ff4c2e2..fffb2618 100644 --- a/src/stdio/putc_unlocked.c +++ b/src/stdio/putc_unlocked.c @@ -1,8 +1,5 @@ -#if 0 - #include <stdio.h> #include "_stdio.h" -#include "_assert.h" #ifdef _POSIX_SOURCE #include <sys/types.h> @@ -18,6 +15,7 @@ int putc_unlocked(int c, FILE *stream) { unsigned char ch = (unsigned char)c; + SIGNAL_SAFE(0); ASSERT_NONNULL(stream); stream->buf[stream->bpos++] = ch; @@ -43,6 +41,3 @@ RETURN_SUCCESS(ARGUMENT(c)) RETURN_FAILURE(CONSTANT(EOF)) POSIX(199506) */ - - -#endif diff --git a/src/stdio/putchar.c b/src/stdio/putchar.c index d42a0836..21f1559e 100644 --- a/src/stdio/putchar.c +++ b/src/stdio/putchar.c @@ -1,11 +1,11 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" /** write a character to stdout **/ int putchar(int c) { + SIGNAL_SAFE(0); /* RETURN_SUCCESS(c); RETURN_FAILURE(CONSTANT(EOF)); @@ -21,6 +21,3 @@ IDENTIFIER(stdout). /* STDC(1) */ - - -#endif diff --git a/src/stdio/putchar_unlocked.c b/src/stdio/putchar_unlocked.c index be048b20..f998bf10 100644 --- a/src/stdio/putchar_unlocked.c +++ b/src/stdio/putchar_unlocked.c @@ -1,15 +1,11 @@ -#if 0 - #include <stdio.h> int putchar_unlocked(int c) { + SIGNAL_SAFE(0); return putc_unlocked(c, stdout); } /* POSIX(199506) */ - - -#endif diff --git a/src/stdio/puts.c b/src/stdio/puts.c index 1e73158c..3392228e 100644 --- a/src/stdio/puts.c +++ b/src/stdio/puts.c @@ -1,14 +1,14 @@ -#if 0 - #include <stdio.h> #include "_stdio.h" -/** write a string to stoud **/ +/** write a string to stdout **/ int puts(const char *s) { int ret = 1; + SIGNAL_SAFE(0); + flockfile(stdout); while (*s) { @@ -41,6 +41,3 @@ followed by a newline. The terminated CHAR(\0) is not written. /* STDC(1) */ - - -#endif diff --git a/src/stdio/putw.c b/src/stdio/putw.c index 19ea92b7..fb18c445 100644 --- a/src/stdio/putw.c +++ b/src/stdio/putw.c @@ -1,16 +1,14 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" # define _XOPEN_LEGACY 500 int putw(int w, FILE *stream) { + SIGNAL_SAFE(0); + (void)w; (void)stream; } /* XOPEN(4,600) */ - - -#endif diff --git a/src/stdio/remove.c b/src/stdio/remove.c index 56c678db..2ac91743 100644 --- a/src/stdio/remove.c +++ b/src/stdio/remove.c @@ -1,5 +1,4 @@ #if 0 - #ifndef _POSIX_SOURCE #define _POSIX_SOURCE #define POSIX_FORCED @@ -22,6 +21,9 @@ int remove(const char *filename) { struct stat st; + + SIGNAL_SAFE(0); + stat(filename, &st); if (S_ISDIR(st.st_mode)) { return rmdir(filename); @@ -39,5 +41,4 @@ IMPLEMENTATION(Whether the file is removed if it is open) STDC(1) */ - #endif diff --git a/src/stdio/rename.c b/src/stdio/rename.c index 3a736287..84d0df35 100644 --- a/src/stdio/rename.c +++ b/src/stdio/rename.c @@ -1,13 +1,13 @@ -#if 0 - #include <errno.h> #include <stdio.h> +#include "_stdio.h" #include "_syscall.h" /** rename a file **/ int rename(const char *old, const char *new) { + SIGNAL_SAFE(0); SYSCALL(rename, int, -1, old, new, 0, 0, 0, 0); } @@ -20,6 +20,3 @@ ARGUMENT(new). IMPLEMENTATION(Behavior if ARGUMENT(new) exists prior to THIS() being called) STDC(1) */ - - -#endif diff --git a/src/stdio/rewind.c b/src/stdio/rewind.c index 200534fe..1cdeee44 100644 --- a/src/stdio/rewind.c +++ b/src/stdio/rewind.c @@ -1,11 +1,11 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" /** reset file position indicator **/ void rewind(FILE *stream) { + SIGNAL_SAFE(0); fseek(stream, 0L, SEEK_SET); clearerr(stream); } @@ -18,6 +18,3 @@ beginning of the file. The error indicator will be cleared. /* STDC(1) */ - - -#endif diff --git a/src/stdio/scanf.c b/src/stdio/scanf.c index b75eb59e..d7de9a7c 100644 --- a/src/stdio/scanf.c +++ b/src/stdio/scanf.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdarg.h> #include <stdio.h> #include "_stdio.h" @@ -11,6 +9,9 @@ int scanf(const char * restrict format, ...) int ret = 0; va_list ap; struct io_options opt = {0}; + + SIGNAL_SAFE(0); + opt.fnname = "scanf"; opt.stream = stdout; va_start(ap, format); @@ -32,6 +33,3 @@ FIXME: scanf format goes here /* STDC(1) */ - - -#endif diff --git a/src/stdio/scanf_s.c b/src/stdio/scanf_s.c index 2d31e597..d4618cd7 100644 --- a/src/stdio/scanf_s.c +++ b/src/stdio/scanf_s.c @@ -1,11 +1,12 @@ -#if 0 - #include <stdio.h> #include <stdarg.h> +#include "_stdio.h" /** read formatted input **/ int scanf_s(const char * restrict format, ...) { + SIGNAL_SAFE(0); + va_list ap; va_start(ap, format); int ret = vfscanf_s(stdin, format, ap); @@ -30,6 +31,3 @@ FIXME: scanf format goes here /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/setbuf.c b/src/stdio/setbuf.c index ce8ad682..ddf38856 100644 --- a/src/stdio/setbuf.c +++ b/src/stdio/setbuf.c @@ -1,11 +1,12 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" /** specify file stream buffer **/ void setbuf(FILE * restrict stream, char * restrict buf) { + SIGNAL_SAFE(0); + if (buf) { setvbuf(stream, buf, _IOFBF, BUFSIZ); } else { @@ -26,6 +27,3 @@ equivalent of: /* STDC(1) */ - - -#endif diff --git a/src/stdio/setvbuf.c b/src/stdio/setvbuf.c index 5b143ecd..a6f37fb0 100644 --- a/src/stdio/setvbuf.c +++ b/src/stdio/setvbuf.c @@ -1,5 +1,3 @@ -#if 0 - #include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -9,6 +7,8 @@ int setvbuf(FILE *stream, char *buf, int mode, size_t size) { + SIGNAL_SAFE(0); + flockfile(stream); if (!f_is_open(stream)) { @@ -78,6 +78,3 @@ The ARGUMENT(size) argument specifies the size of the buffer. /* STDC(1) */ - - -#endif diff --git a/src/stdio/snprintf.c b/src/stdio/snprintf.c index 9cac9a7f..9bf6d17b 100644 --- a/src/stdio/snprintf.c +++ b/src/stdio/snprintf.c @@ -1,11 +1,11 @@ -#if 0 - #include <stdio.h> #include <stdarg.h> #include "_stdio.h" int snprintf(char * restrict s, size_t n, const char * restrict format, ...) { + SIGNAL_SAFE(0); + struct io_options opt = { .fnname = __func__, .string = s, @@ -23,6 +23,3 @@ int snprintf(char * restrict s, size_t n, const char * restrict format, ...) /* STDC(199901) */ - - -#endif diff --git a/src/stdio/snprintf_s.c b/src/stdio/snprintf_s.c index 7856fd40..aa7768f9 100644 --- a/src/stdio/snprintf_s.c +++ b/src/stdio/snprintf_s.c @@ -1,15 +1,13 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" int snprintf_s( char * restrict s, rsize_t n, const char * restrict format, ...) { - __C_EXT(1, 201112L); + SIGNAL_SAFE(0); + (void)s; (void)n; (void)format; + return 0; } /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/sprintf.c b/src/stdio/sprintf.c index cd3fe63b..ab1729b2 100644 --- a/src/stdio/sprintf.c +++ b/src/stdio/sprintf.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdarg.h> #include <stdio.h> #include "_stdio.h" @@ -11,6 +9,9 @@ int sprintf(char * restrict s, const char * restrict format, ...) int ret = 0; va_list ap; struct io_options opt = {0}; + + SIGNAL_SAFE(0); + opt.fnname = "sprintf"; opt.string = s; opt.maxlen = (size_t)-1; @@ -32,6 +33,3 @@ FUNCTION(printf). /* STDC(1) */ - - -#endif diff --git a/src/stdio/sprintf_s.c b/src/stdio/sprintf_s.c index dd70f149..81613ecb 100644 --- a/src/stdio/sprintf_s.c +++ b/src/stdio/sprintf_s.c @@ -1,11 +1,14 @@ -#if 0 - #include <stdio.h> #include <stdarg.h> +#include "_stdio.h" /** write formatted output to a string **/ int sprintf_s(char * restrict s, rsize_t n, const char * restrict format, ...) { + SIGNAL_SAFE(0); + + (void)n; + va_list ap; va_start(ap, format); int ret = vsprintf(s, format, ap); @@ -29,6 +32,3 @@ fn(printf). /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/sscanf.c b/src/stdio/sscanf.c index 520e0669..125a49f6 100644 --- a/src/stdio/sscanf.c +++ b/src/stdio/sscanf.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdarg.h> #include <stdio.h> #include "_stdio.h" @@ -11,6 +9,9 @@ int sscanf(const char * restrict s, const char * restrict format, ...) int ret = 0; va_list ap; struct io_options opt = {0}; + + SIGNAL_SAFE(0); + opt.fnname = "sscanf"; opt.string = (char *)s; va_start(ap, format); @@ -32,6 +33,3 @@ FUNCTION(scanf). /* STDC(1) */ - - -#endif diff --git a/src/stdio/sscanf_s.c b/src/stdio/sscanf_s.c index be9033aa..20249496 100644 --- a/src/stdio/sscanf_s.c +++ b/src/stdio/sscanf_s.c @@ -1,11 +1,12 @@ -#if 0 - #include <stdio.h> #include <stdarg.h> +#include "_stdio.h" /** read formatted input from a string **/ int sscanf_s(const char * restrict s, const char * restrict format, ...) { + SIGNAL_SAFE(0); + va_list ap; va_start(ap, format); int ret = vsscanf(s, format, ap); @@ -30,6 +31,3 @@ fn(scanf). /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/tempnam.c b/src/stdio/tempnam.c index 719f94ca..e40ec537 100644 --- a/src/stdio/tempnam.c +++ b/src/stdio/tempnam.c @@ -1,15 +1,12 @@ -#if 0 - #include <stdio.h> char * tempnam(const char * dir, const char * pfx) { + SIGNAL_SAFE(0); + (void)dir; (void)pfx; return NULL; } /* XOPEN(4) */ - - -#endif diff --git a/src/stdio/tmpfile.c b/src/stdio/tmpfile.c index b7ae0e77..f19bbdcf 100644 --- a/src/stdio/tmpfile.c +++ b/src/stdio/tmpfile.c @@ -1,13 +1,17 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" +#undef tmpfile /** open a temporary file stream **/ FILE * tmpfile(void) { char *path = "FIXME: A temporary file name *not* calling tmpnam()"; - FILE *f = fopen(path, "w+"); + FILE *f = NULL; + + SIGNAL_SAFE(0); + + f = fopen(path, "w+"); if (f) { /* FIXME: set flag for temporary in FILE struct */ } else { @@ -32,6 +36,3 @@ or when the program exits. IMPLEMENTATION(Whether the temporary file is removed if the program terminates abnormally) STDC(1) */ - - -#endif diff --git a/src/stdio/tmpfile_s.c b/src/stdio/tmpfile_s.c index 84bff0c8..e0562cfd 100644 --- a/src/stdio/tmpfile_s.c +++ b/src/stdio/tmpfile_s.c @@ -1,11 +1,11 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" /* open a temporary file stream */ errno_t tmpfile_s(FILE * restrict * restrict streamptr) { - __C_EXT(1, 201112L); + SIGNAL_SAFE(0); + (void)streamptr; return 0; } @@ -26,6 +26,3 @@ be automatically removed when closed by fn(fclose) or when the program exits. /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/tmpnam.c b/src/stdio/tmpnam.c index b4ac6b8e..af4f2012 100644 --- a/src/stdio/tmpnam.c +++ b/src/stdio/tmpnam.c @@ -1,6 +1,5 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" /** generate a temporary file name **/ @@ -9,6 +8,7 @@ char * tmpnam(char *s) static int ntimescalled = 0; static char path[L_tmpnam]; + SIGNAL_SAFE(0); if (ntimescalled >= TMP_MAX) { return NULL; } @@ -42,6 +42,3 @@ this array. IMPLEMENTATION(Behavior if THIS() is called more than CONSTANT(TMP_MAX) times) STDC(1) */ - - -#endif diff --git a/src/stdio/tmpnam_s.c b/src/stdio/tmpnam_s.c index 3f5462a0..ada58a78 100644 --- a/src/stdio/tmpnam_s.c +++ b/src/stdio/tmpnam_s.c @@ -1,11 +1,12 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" /** generate a temporary file name **/ errno_t tmpnam_s(char *s, rsize_t maxsize) { - __C_EXT(1, 201112L); + SIGNAL_SAFE(0); + (void)maxsize; + static int ntimescalled = 0; static char path[L_tmpnam]; @@ -43,6 +44,3 @@ macro(L_tmpnam) characters. The temporary name will be copied to this array. /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/ungetc.c b/src/stdio/ungetc.c index a3fc7d0a..ca579290 100644 --- a/src/stdio/ungetc.c +++ b/src/stdio/ungetc.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdio.h> #include "_stdio.h" @@ -7,6 +5,7 @@ int ungetc(int c, FILE *stream) { + SIGNAL_SAFE(0); (void)c; (void)stream; /* TODO */ /* @@ -39,6 +38,3 @@ is obsolete in ISO/IEC 9899:1999. /* STDC(1) */ - - -#endif diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c index 9eea0bed..0e3f9557 100644 --- a/src/stdio/vfprintf.c +++ b/src/stdio/vfprintf.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdarg.h> #include <stdio.h> #include "_stdio.h" @@ -10,6 +8,7 @@ int vfprintf(FILE * restrict stream, const char * restrict format, va_list arg) { int ret = 0; struct io_options opt = {0}; + SIGNAL_SAFE(0); opt.fnname = "vfprintf"; opt.stream = stream; ret = __printf(&opt, format, arg); @@ -31,6 +30,3 @@ responsible for this. /* STDC(1) */ - - -#endif diff --git a/src/stdio/vfprintf_s.c b/src/stdio/vfprintf_s.c index 9de51739..941b03c0 100644 --- a/src/stdio/vfprintf_s.c +++ b/src/stdio/vfprintf_s.c @@ -1,12 +1,11 @@ -#if 0 - #include <stdio.h> -#include "__stdio.h" #include <stdarg.h> +#include "_stdio.h" /** write formatted output to a file stream **/ int vfprintf_s(FILE * restrict stream, const char * restrict format, va_list arg) { + SIGNAL_SAFE(0); struct io_options opt = { .fnname = __func__, .stream = stream, @@ -33,6 +32,3 @@ responsible for this. /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/vfscanf.c b/src/stdio/vfscanf.c index 271ac15f..0df43d92 100644 --- a/src/stdio/vfscanf.c +++ b/src/stdio/vfscanf.c @@ -1,10 +1,9 @@ -#if 0 - #include <stdio.h> #include "_stdio.h" int vfscanf(FILE * restrict stream, const char * restrict format, va_list arg) { + SIGNAL_SAFE(0); struct io_options opt = { .fnname = __func__, .stream = stream, @@ -16,6 +15,3 @@ int vfscanf(FILE * restrict stream, const char * restrict format, va_list arg) /* STDC(199901) */ - - -#endif diff --git a/src/stdio/vfscanf_s.c b/src/stdio/vfscanf_s.c index 7e8008a2..ca7b84d1 100644 --- a/src/stdio/vfscanf_s.c +++ b/src/stdio/vfscanf_s.c @@ -1,15 +1,13 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" int vfscanf_s(FILE * restrict stream, const char * restrict format, va_list arg) { - __C_EXT(1, 201112L); + SIGNAL_SAFE(0); + (void)stream; (void)format; (void)arg; + return 0; } /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/vprintf.c b/src/stdio/vprintf.c index 9c8bea83..00c21419 100644 --- a/src/stdio/vprintf.c +++ b/src/stdio/vprintf.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdio.h> #include <stdarg.h> #include "_stdio.h" @@ -9,6 +7,9 @@ int vprintf(const char * restrict format, va_list arg) { int ret = 0; struct io_options opt = {0}; + + SIGNAL_SAFE(0); + opt.fnname = "vfprintf"; opt.stream = stdout; ret = __printf(&opt, format, arg); @@ -29,6 +30,3 @@ responsible for this. /* STDC(1) */ - - -#endif diff --git a/src/stdio/vprintf_s.c b/src/stdio/vprintf_s.c index 4d905bbc..5f462e7e 100644 --- a/src/stdio/vprintf_s.c +++ b/src/stdio/vprintf_s.c @@ -1,11 +1,10 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" /** write formatted output **/ int vprintf_s(const char * restrict format, va_list arg) { - __C_EXT(1, 201112L); + SIGNAL_SAFE(0); return vfprintf(stdout, format, arg); } @@ -28,6 +27,3 @@ responsible for this. /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/vscanf.c b/src/stdio/vscanf.c index 990a8584..701ac478 100644 --- a/src/stdio/vscanf.c +++ b/src/stdio/vscanf.c @@ -1,15 +1,12 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" int vscanf(const char * restrict format, va_list arg) { + SIGNAL_SAFE(0); return vfscanf(stdin, format, arg); } /* STDC(199901) */ - - -#endif diff --git a/src/stdio/vscanf_s.c b/src/stdio/vscanf_s.c index 02b2941a..d8bf0418 100644 --- a/src/stdio/vscanf_s.c +++ b/src/stdio/vscanf_s.c @@ -1,16 +1,12 @@ -#if 0 - #include <stdio.h> +#include "_stdio.h" int vscanf_s(const char * restrict format, va_list arg) { - __C_EXT(1, 201112L); + SIGNAL_SAFE(0); return vfscanf(stdin, format, arg); } /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/vsnprintf.c b/src/stdio/vsnprintf.c index 14636805..3fa18cf4 100644 --- a/src/stdio/vsnprintf.c +++ b/src/stdio/vsnprintf.c @@ -1,11 +1,10 @@ -#if 0 - #include <stdio.h> #include <stdarg.h> #include "_stdio.h" int vsnprintf(char * restrict s, size_t n, const char *format, va_list arg) { + SIGNAL_SAFE(0); struct io_options opt = { .fnname = __func__, .string = s, @@ -18,6 +17,3 @@ int vsnprintf(char * restrict s, size_t n, const char *format, va_list arg) /* STDC(199901) */ - - -#endif diff --git a/src/stdio/vsnprintf_s.c b/src/stdio/vsnprintf_s.c index f1dbdbd1..3d094fe5 100644 --- a/src/stdio/vsnprintf_s.c +++ b/src/stdio/vsnprintf_s.c @@ -1,21 +1,17 @@ -#if 0 - #include <stdio.h> #include "_stdio.h" int vsnprintf_s(char * restrict s, rsize_t n, const char * restrict format, va_list arg) { + SIGNAL_SAFE(0); struct io_options opt = { .fnname = __func__, .string = s, .maxlen = n, }; - return __printf(&opt, format, ap); + return __printf(&opt, format, arg); } /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/vsprintf.c b/src/stdio/vsprintf.c index 1954158a..ef4d40a0 100644 --- a/src/stdio/vsprintf.c +++ b/src/stdio/vsprintf.c @@ -1,5 +1,3 @@ -#if 0 - #include <stdarg.h> #include <stdio.h> #include "_stdio.h" @@ -10,6 +8,9 @@ int vsprintf(char *s, const char *format, va_list arg) { int ret = 0; struct io_options opt = {0}; + + SIGNAL_SAFE(0); + opt.fnname = "fprintf"; opt.string = s; opt.maxlen = (size_t)-1; @@ -31,6 +32,3 @@ responsible for this. /* STDC(1) */ - - -#endif diff --git a/src/stdio/vsprintf_s.c b/src/stdio/vsprintf_s.c index 002e5366..02a0899f 100644 --- a/src/stdio/vsprintf_s.c +++ b/src/stdio/vsprintf_s.c @@ -1,13 +1,13 @@ -#if 0 - #include <stdio.h> #include <stdarg.h> #include <stdint.h> +#include "_stdio.h" /** write formatted output to a string **/ int vsprintf_s(char *s, rsize_t n, const char *format, va_list arg) { - __C_EXT(1, 201112L); + SIGNAL_SAFE(0); + (void)n; return vsnprintf(s, SIZE_MAX, format, arg); } @@ -29,6 +29,3 @@ responsible for this. /* CEXT1(201112) */ - - -#endif diff --git a/src/stdio/vsscanf.c b/src/stdio/vsscanf.c index ffda877b..b803e262 100644 --- a/src/stdio/vsscanf.c +++ b/src/stdio/vsscanf.c @@ -1,11 +1,11 @@ -#if 0 - #include <stdio.h> #include <stdarg.h> #include "_stdio.h" int vsscanf(const char * restrict s, const char * restrict format, va_list arg) { + SIGNAL_SAFE(0); + struct io_options opt = { .fnname = __func__, .string = (char*)s, @@ -17,6 +17,3 @@ int vsscanf(const char * restrict s, const char * restrict format, va_list arg) /* STDC(199901) */ - - -#endif diff --git a/src/stdio/vsscanf_s.c b/src/stdio/vsscanf_s.c index 1e94ef1b..3e3ea62f 100644 --- a/src/stdio/vsscanf_s.c +++ b/src/stdio/vsscanf_s.c @@ -1,15 +1,13 @@ -#if 0 - #include <stdarg.h> +#include "_stdio.h" int vsscanf_s(const char * restrict s, const char * restrict format, va_list arg) { - __C_EXT(1, 201112L); + SIGNAL_SAFE(0); + (void)s; (void)format; (void)arg; + return 0; } /* CEXT1(201112) */ - - -#endif |