From fa04f2dc766c76f2caa44a4b8429185dde6a66b0 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 9 Apr 2023 10:48:58 +0100 Subject: ash: remove ASH_IGNORE_CR config option No further problems with CRLF handling have been reported. Remove the configuration option that allowed some recent changes to be turned off. Also, prevent some WIN32 code from being included in the POSIX build. The faulty code is from commit 64c8f5f3d (ash: add support for INT trap). These changes don't alter the default WIN32 build. --- configs/make32_defconfig | 1 - configs/make64_defconfig | 1 - configs/mingw32_defconfig | 1 - configs/mingw64_defconfig | 1 - shell/ash.c | 28 +++++++++------------------- shell/shell_common.c | 11 +---------- 6 files changed, 10 insertions(+), 33 deletions(-) diff --git a/configs/make32_defconfig b/configs/make32_defconfig index 354c2eb87..bafb6a63a 100644 --- a/configs/make32_defconfig +++ b/configs/make32_defconfig @@ -1158,7 +1158,6 @@ CONFIG_ASH_GETOPTS=y CONFIG_ASH_CMDCMD=y CONFIG_ASH_NOCONSOLE=y CONFIG_ASH_NOCASEGLOB=y -CONFIG_ASH_IGNORE_CR=y # CONFIG_CTTYHACK is not set # CONFIG_HUSH is not set # CONFIG_SHELL_HUSH is not set diff --git a/configs/make64_defconfig b/configs/make64_defconfig index 6564603c8..441c23b5a 100644 --- a/configs/make64_defconfig +++ b/configs/make64_defconfig @@ -1158,7 +1158,6 @@ CONFIG_ASH_GETOPTS=y CONFIG_ASH_CMDCMD=y CONFIG_ASH_NOCONSOLE=y CONFIG_ASH_NOCASEGLOB=y -CONFIG_ASH_IGNORE_CR=y # CONFIG_CTTYHACK is not set # CONFIG_HUSH is not set # CONFIG_SHELL_HUSH is not set diff --git a/configs/mingw32_defconfig b/configs/mingw32_defconfig index 4918b2f4f..16a7fd2d1 100644 --- a/configs/mingw32_defconfig +++ b/configs/mingw32_defconfig @@ -1170,7 +1170,6 @@ CONFIG_ASH_GETOPTS=y CONFIG_ASH_CMDCMD=y CONFIG_ASH_NOCONSOLE=y CONFIG_ASH_NOCASEGLOB=y -CONFIG_ASH_IGNORE_CR=y # CONFIG_CTTYHACK is not set # CONFIG_HUSH is not set # CONFIG_SHELL_HUSH is not set diff --git a/configs/mingw64_defconfig b/configs/mingw64_defconfig index 96e407644..96a5bdb0e 100644 --- a/configs/mingw64_defconfig +++ b/configs/mingw64_defconfig @@ -1170,7 +1170,6 @@ CONFIG_ASH_GETOPTS=y CONFIG_ASH_CMDCMD=y CONFIG_ASH_NOCONSOLE=y CONFIG_ASH_NOCASEGLOB=y -CONFIG_ASH_IGNORE_CR=y # CONFIG_CTTYHACK is not set # CONFIG_HUSH is not set # CONFIG_SHELL_HUSH is not set diff --git a/shell/ash.c b/shell/ash.c index 77670ebb4..51bf95377 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -192,16 +192,6 @@ //config: Enable support for the 'nocaseglob' option, which allows //config: case-insensitive filename globbing. //config: -//config:config ASH_IGNORE_CR -//config: bool "Ignore CR in CRLF line endings" -//config: default y -//config: depends on (ASH || SH_IS_ASH || BASH_IS_ASH) && PLATFORM_MINGW32 -//config: help -//config: Allow CRs to be ignored when they appear in CRLF line endings -//config: but not in other circumstances. This isn't a general-purpose -//config: option: it only covers certain new cases which are under test. -//config: Enabled by default. May be removed in future. -//config: //config:endif # ash options //applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) @@ -6807,7 +6797,7 @@ ifsbreakup(char *string, struct arglist *arglist) const char *ifs, *realifs; int ifsspc; int nulonly; -#if ENABLE_ASH_IGNORE_CR +#if ENABLE_PLATFORM_MINGW32 int lshift = 0; #endif @@ -6820,13 +6810,13 @@ ifsbreakup(char *string, struct arglist *arglist) do { int afternul; -#if ENABLE_ASH_IGNORE_CR +#if ENABLE_PLATFORM_MINGW32 /* Adjust region offsets for left-shifted string. */ ifsp->begoff -= lshift; ifsp->endoff -= lshift; #endif p = string + ifsp->begoff; -#if ENABLE_ASH_IGNORE_CR +#if ENABLE_PLATFORM_MINGW32 if (ifsp->endoff > ifsp->begoff + 1) { /* Transform CRLF to LF. Skip regions having zero or * one characters: they can't contain CRLF. If the @@ -11788,7 +11778,7 @@ static void popstring(void) INT_ON; } -#if ENABLE_ASH_IGNORE_CR +#if ENABLE_PLATFORM_MINGW32 /* * Wrapper around nonblock_immune_read() to remove CRs, but only from * CRLF pairs. The tricky part is handling a CR at the end of the buffer. @@ -11846,7 +11836,7 @@ preadfd(void) #if ENABLE_FEATURE_EDITING /* retry: */ if (!iflag || g_parsefile->pf_fd != STDIN_FILENO) -#if ENABLE_ASH_IGNORE_CR +#if ENABLE_PLATFORM_MINGW32 nr = nonblock_immune_wrapper(g_parsefile, buf, IBUFSIZ - 1); #else nr = nonblock_immune_read(g_parsefile->pf_fd, buf, IBUFSIZ - 1); @@ -11932,7 +11922,7 @@ preadfd(void) } } #else -# if ENABLE_ASH_IGNORE_CR +# if ENABLE_PLATFORM_MINGW32 nr = nonblock_immune_wrapper(g_parsefile, buf, IBUFSIZ - 1); # else nr = nonblock_immune_read(g_parsefile->pf_fd, buf, IBUFSIZ - 1); @@ -12007,9 +11997,7 @@ preadbuffer(void) more--; c = *q; - /* Remove CR from input buffer as an alternative to ASH_IGNORE_CR. */ - if (c == '\0' || (c == '\r' && - ENABLE_PLATFORM_MINGW32 && !ENABLE_ASH_IGNORE_CR)) { + if (c == '\0') { memmove(q, q + 1, more); } else { q++; @@ -15160,7 +15148,9 @@ trapcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) next: ap++; } +#if ENABLE_PLATFORM_MINGW32 may_have_traps = trap[SIGINT] && trap[SIGINT][0] != '\0'; +#endif return exitcode; } diff --git a/shell/shell_common.c b/shell/shell_common.c index efe8828e4..716d3aebb 100644 --- a/shell/shell_common.c +++ b/shell/shell_common.c @@ -19,11 +19,7 @@ #include "libbb.h" #include "shell_common.h" -#if !ENABLE_PLATFORM_MINGW32 || ENABLE_ASH_IGNORE_CR const char defifsvar[] ALIGN1 = "IFS= \t\n"; -#else -const char defifsvar[] ALIGN1 = "IFS= \t\n\r"; -#endif const char defoptindvar[] ALIGN1 = "OPTIND=1"; /* read builtin */ @@ -261,10 +257,6 @@ shell_builtin_read(struct builtin_read_params *params) c = buffer[bufpos]; #if ENABLE_PLATFORM_MINGW32 -# if !ENABLE_ASH_IGNORE_CR - if (c == '\r') - continue; -# else if (c == '\n') { if (backslash == 2 || (bufpos > 0 && buffer[bufpos - 1] == '\r')) { /* We saw either: @@ -279,11 +271,10 @@ shell_builtin_read(struct builtin_read_params *params) * process ?? */ backslash = 0; } -# endif #endif if (!(read_flags & BUILTIN_READ_RAW)) { if (backslash) { -#if ENABLE_ASH_IGNORE_CR +#if ENABLE_PLATFORM_MINGW32 if (c == '\r') { /* We have BS CR, keep CR for now, might see LF next */ backslash = 2; -- cgit v1.2.3-55-g6feb