From 98e16f25885fa49e30003d39e9b7316163c14e83 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 21 Feb 2023 10:48:20 +0000 Subject: ash: revert changes to handle CRLF in scripts Commit 4b894b60a doesn't seem to have worked out. Revert it and the fix in 6e0a6b7e5. We're now back to removing CRs unconditionally from shell scripts. --- shell/ash.c | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 43b55b259..152ca198d 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -772,11 +772,7 @@ struct strpush { struct strpush *spfree; /* Remember last two characters for pungetc. */ -#if ENABLE_ASH_IGNORE_CR - int lastc[3]; /* Ignoring CRs needs more pungetc. */ -#else int lastc[2]; -#endif /* Number of outstanding calls to pungetc. */ int unget; @@ -801,11 +797,7 @@ struct parsefile { struct strpush *spfree; /* Remember last two characters for pungetc. */ -#if ENABLE_ASH_IGNORE_CR - int lastc[3]; /* Ignoring CRs needs more pungetc. */ -#else int lastc[2]; -#endif /* Number of outstanding calls to pungetc. */ int unget; @@ -3611,11 +3603,7 @@ static const uint8_t syntax_index_table[] ALIGN1 = { /* 10 "\n" */ CNL_CNL_CNL_CNL, /* 11 */ CWORD_CWORD_CWORD_CWORD, /* 12 */ CWORD_CWORD_CWORD_CWORD, -#if ENABLE_ASH_IGNORE_CR - /* 13 */ CSPCL_CWORD_CWORD_CWORD, -#else /* 13 */ CWORD_CWORD_CWORD_CWORD, -#endif /* 14 */ CWORD_CWORD_CWORD_CWORD, /* 15 */ CWORD_CWORD_CWORD_CWORD, /* 16 */ CWORD_CWORD_CWORD_CWORD, @@ -11895,9 +11883,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' || (ENABLE_PLATFORM_MINGW32 && c == '\r')) { memmove(q, q + 1, more); } else { q++; @@ -11985,9 +11971,6 @@ static int __pgetc(void) else c = preadbuffer(); -#if ENABLE_ASH_IGNORE_CR - g_parsefile->lastc[2] = g_parsefile->lastc[1]; -#endif g_parsefile->lastc[1] = g_parsefile->lastc[0]; g_parsefile->lastc[0] = c; @@ -12025,24 +12008,11 @@ pgetc_eatbnl(void) int c; while ((c = pgetc()) == '\\') { -#if !ENABLE_ASH_IGNORE_CR if (pgetc() != '\n') { pungetc(); break; } -#else - int c2 = pgetc(); - if (c2 == '\r') { - if (pgetc() == '\n') - goto eatbnl; - pungetc(); - } - if (c2 != '\n') { - pungetc(); - break; - } - eatbnl: -#endif + nlprompt(); } @@ -13705,7 +13675,7 @@ checkend: { c = pgetc(); } - if (c == '\n' || c == PEOF || (ENABLE_ASH_IGNORE_CR && c == '\r')) { + if (c == '\n' || c == PEOF) { c = PEOF; if (trap_depth == 0) g_parsefile->linno++; @@ -14181,7 +14151,7 @@ xxreadtoken(void) setprompt_if(needprompt, 2); for (;;) { /* until token or start of word found */ c = pgetc_eatbnl(); - if (c == ' ' || c == '\t' || (ENABLE_ASH_IGNORE_CR && c == '\r')) + if (c == ' ' || c == '\t') continue; if (c == '#') { -- cgit v1.2.3-55-g6feb