From 3e282018ffb5806cafafeb5d0d6f8d67c9bb86e8 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Thu, 13 Aug 2020 13:29:45 -0400 Subject: directly replace fputc() and fgetc() with putc_unlocked() and getc_unlocked() when not using POSIX >= 199506 --- src/stdio/__printf.c | 2 ++ src/stdio/fgetc.c | 5 ++++- src/stdio/fputc.c | 5 ++++- src/stdio/getc_unlocked.c | 5 ----- src/stdio/printf.c | 1 - src/stdio/putc_unlocked.c | 5 ----- 6 files changed, 10 insertions(+), 13 deletions(-) (limited to 'src/stdio') diff --git a/src/stdio/__printf.c b/src/stdio/__printf.c index af3e3e6a..5b27bbdd 100644 --- a/src/stdio/__printf.c +++ b/src/stdio/__printf.c @@ -1,5 +1,7 @@ #include "_stdio.h" #include "stddef.h" +#include "../wctype/wint_t.c" +#include "../wctype/wctrans_t.c" #include "wchar.h" #include "inttypes.h" #include "unistd.h" diff --git a/src/stdio/fgetc.c b/src/stdio/fgetc.c index f03fd545..56f1a348 100644 --- a/src/stdio/fgetc.c +++ b/src/stdio/fgetc.c @@ -3,8 +3,9 @@ #if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 199506L #undef getc_unlocked +#define getc_unlocked fgetc #include "getc_unlocked.c" -#endif +#else /** read a character from a file stream **/ int fgetc(FILE *stream) @@ -19,6 +20,8 @@ int fgetc(FILE *stream) return c; } +#endif + /*** reads the next character from ARGUMENT(stream) as an TYPE(unsigned char) converted to an TYPE(int). The file position indicator diff --git a/src/stdio/fputc.c b/src/stdio/fputc.c index 3123103b..1e44b85c 100644 --- a/src/stdio/fputc.c +++ b/src/stdio/fputc.c @@ -3,8 +3,9 @@ #if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 199506L #undef putc_unlocked +#define putc_unlocked fputc #include "putc_unlocked.c" -#endif +#else /** write a character to a file stream **/ int fputc(int c, FILE *stream) @@ -16,6 +17,8 @@ int fputc(int c, FILE *stream) return ret; } +#endif + /*** writes the character ARGUMENT(c) (converted to an TYPE(unsigned char)) to ARGUMENT(stream). The character is written at the current diff --git a/src/stdio/getc_unlocked.c b/src/stdio/getc_unlocked.c index 8e688a64..c5186bcc 100644 --- a/src/stdio/getc_unlocked.c +++ b/src/stdio/getc_unlocked.c @@ -9,11 +9,6 @@ #define read(_fd, _buf, _size) __syscall(__syscall_lookup(read), _fd, _buf, _size) #endif -#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 199506 -#define getc_unlocked __getc_unlocked - static -#endif - int getc_unlocked(FILE * stream) { char c = 0; diff --git a/src/stdio/printf.c b/src/stdio/printf.c index c7bb7a91..1dedbbea 100644 --- a/src/stdio/printf.c +++ b/src/stdio/printf.c @@ -5,7 +5,6 @@ /** write formatted output **/ int printf(const char *format, ...) { - int ret = 0; va_list ap; struct io_options opt = {0}; diff --git a/src/stdio/putc_unlocked.c b/src/stdio/putc_unlocked.c index 4f658eb5..99af7b39 100644 --- a/src/stdio/putc_unlocked.c +++ b/src/stdio/putc_unlocked.c @@ -9,11 +9,6 @@ #define write(_fd, _buf, _size) __syscall(__syscall_lookup(write), _fd, _buf, _size) #endif -#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 199506 -#define putc_unlocked __putc_unlocked - static -#endif - /** write a character to a file stream with explicit client locking **/ int putc_unlocked(int c, FILE *stream) { -- cgit v1.2.1