Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 0 additions & 23 deletions libs/libc/stdio/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 1 addition & 17 deletions libs/libc/stdio/lib_getdelim.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
40 changes: 0 additions & 40 deletions libs/libc/stdio/lib_libfgets.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
****************************************************************************/
Expand All @@ -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
}
}

Expand Down Expand Up @@ -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)
{
Expand Down