From 64991ac56ea5f11b8a68d9a24efcff210805569f Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Wed, 22 Feb 2023 21:02:21 +0800 Subject: [PATCH] stdio: Remove CONFIG_EOL_IS_XXX Signed-off-by: Huang Qi --- .../configs/wamr_wasi_debug/defconfig | 1 - libs/libc/stdio/Kconfig | 23 ----------- libs/libc/stdio/lib_getdelim.c | 18 +-------- libs/libc/stdio/lib_libfgets.c | 40 ------------------- 4 files changed, 1 insertion(+), 81 deletions(-) diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/wamr_wasi_debug/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/wamr_wasi_debug/defconfig index 3440e18ef7047..b2b7e76dee724 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/wamr_wasi_debug/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/wamr_wasi_debug/defconfig @@ -42,7 +42,6 @@ CONFIG_DEV_ZERO=y CONFIG_DRIVERS_IEEE80211=y CONFIG_DRIVERS_WIRELESS=y CONFIG_EFUSE=y -CONFIG_EOL_IS_CR=y CONFIG_ESP32_EFUSE=y CONFIG_ESP32_IRAM_HEAP=y CONFIG_ESP32_RTC_HEAP=y diff --git a/libs/libc/stdio/Kconfig b/libs/libc/stdio/Kconfig index 7a198e67ce882..c3417e9e03c05 100644 --- a/libs/libc/stdio/Kconfig +++ b/libs/libc/stdio/Kconfig @@ -106,27 +106,4 @@ config LIBC_SCANSET ---help--- Add scanset support to sscanf(). -choice - prompt "Newline Options" - default EOL_IS_EITHER_CRLF - ---help--- - This selection determines the line terminating character that is used. - Some environments may return CR as end-of-line, others LF, and others - both. If not specified, the default is either CR or LF (but not both) - as the line terminating character. - -config EOL_IS_CR - bool "EOL is CR" - -config EOL_IS_LF - bool "EOL is LF" - -config EOL_IS_BOTH_CRLF - bool "EOL is CR and LF" - -config EOL_IS_EITHER_CRLF - bool "EOL is CR or LF" - -endchoice - endmenu #Standard C I/O diff --git a/libs/libc/stdio/lib_getdelim.c b/libs/libc/stdio/lib_getdelim.c index 8598b5b5c3c01..4b17028065662 100644 --- a/libs/libc/stdio/lib_getdelim.c +++ b/libs/libc/stdio/lib_getdelim.c @@ -32,20 +32,6 @@ * Pre-processor Definitions ****************************************************************************/ -/* Some environments may return CR as end-of-line, others LF, and others - * both. Because of the definition of the getline() function, it can handle - * only single character line terminators. - */ - -#undef HAVE_GETLINE -#if defined(CONFIG_EOL_IS_CR) -# define HAVE_GETLINE 1 -# define EOLCH '\r' -#elif defined(CONFIG_EOL_IS_LF) -# define HAVE_GETLINE 1 -# define EOLCH '\n' -#endif - #define BUFSIZE_INIT 64 #define BUFSIZE_INCR 32 @@ -232,9 +218,7 @@ ssize_t getdelim(FAR char **lineptr, size_t *n, int delimiter, * ****************************************************************************/ -#ifdef HAVE_GETLINE ssize_t getline(FAR char **lineptr, size_t *n, FAR FILE *stream) { - return getdelim(lineptr, n, EOLCH, stream); + return getdelim(lineptr, n, '\n', stream); } -#endif diff --git a/libs/libc/stdio/lib_libfgets.c b/libs/libc/stdio/lib_libfgets.c index 7d7e949906d37..9e95b6884e528 100644 --- a/libs/libc/stdio/lib_libfgets.c +++ b/libs/libc/stdio/lib_libfgets.c @@ -38,34 +38,6 @@ * Pre-processor Definitions ****************************************************************************/ -/* Some environments may return CR as end-of-line, others LF, and others - * both. If not specified, the logic here assumes either (but not both) as - * the default. - */ - -#if defined(CONFIG_EOL_IS_CR) -# undef CONFIG_EOL_IS_LF -# undef CONFIG_EOL_IS_BOTH_CRLF -# undef CONFIG_EOL_IS_EITHER_CRLF -#elif defined(CONFIG_EOL_IS_LF) -# undef CONFIG_EOL_IS_CR -# undef CONFIG_EOL_IS_BOTH_CRLF -# undef CONFIG_EOL_IS_EITHER_CRLF -#elif defined(CONFIG_EOL_IS_BOTH_CRLF) -# undef CONFIG_EOL_IS_CR -# undef CONFIG_EOL_IS_LF -# undef CONFIG_EOL_IS_EITHER_CRLF -#elif defined(CONFIG_EOL_IS_EITHER_CRLF) -# undef CONFIG_EOL_IS_CR -# undef CONFIG_EOL_IS_LF -# undef CONFIG_EOL_IS_BOTH_CRLF -#else -# undef CONFIG_EOL_IS_CR -# undef CONFIG_EOL_IS_LF -# undef CONFIG_EOL_IS_BOTH_CRLF -# define CONFIG_EOL_IS_EITHER_CRLF 1 -#endif - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -90,13 +62,7 @@ static void consume_eol(FILE *stream, bool consume) { ch = fgetc(stream); } -#if defined(CONFIG_EOL_IS_LF) || defined(CONFIG_EOL_IS_BOTH_CRLF) while (ch != EOF && ch != '\n'); -#elif defined(CONFIG_EOL_IS_CR) - while (ch != EOF && ch != '\r'); -#else /* elif defined(CONFIG_EOL_IS_EITHER_CRLF) */ - while (ch != EOF && ch != '\n' && ch != '\r'); -#endif } } @@ -174,13 +140,7 @@ FAR char *lib_fgets(FAR char *buf, size_t buflen, FILE *stream, * others both. */ -#if defined(CONFIG_EOL_IS_LF) || defined(CONFIG_EOL_IS_BOTH_CRLF) if (ch == '\n') -#elif defined(CONFIG_EOL_IS_CR) - if (ch == '\r') -#else /* elif defined(CONFIG_EOL_IS_EITHER_CRLF) */ - if (ch == '\n' || ch == '\r') -#endif { if (keepnl) {