mirror of
https://github.com/apache/nuttx.git
synced 2026-09-21 21:47:28 +08:00
stdio: Remove CONFIG_EOL_IS_XXX
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 @@ errout:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user