aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-02-21 10:48:20 +0000
committerRon Yorston <rmy@pobox.com>2023-02-21 10:48:20 +0000
commit98e16f25885fa49e30003d39e9b7316163c14e83 (patch)
tree15ec4a2291300144507b6c15e992d42efd6de12b
parentea9af0c3806a0bfefa81e78d6e3542ae22049723 (diff)
downloadbusybox-w32-98e16f25885fa49e30003d39e9b7316163c14e83.tar.gz
busybox-w32-98e16f25885fa49e30003d39e9b7316163c14e83.tar.bz2
busybox-w32-98e16f25885fa49e30003d39e9b7316163c14e83.zip
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.
-rw-r--r--shell/ash.c38
1 files changed, 4 insertions, 34 deletions
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 {
772 struct strpush *spfree; 772 struct strpush *spfree;
773 773
774 /* Remember last two characters for pungetc. */ 774 /* Remember last two characters for pungetc. */
775#if ENABLE_ASH_IGNORE_CR
776 int lastc[3]; /* Ignoring CRs needs more pungetc. */
777#else
778 int lastc[2]; 775 int lastc[2];
779#endif
780 776
781 /* Number of outstanding calls to pungetc. */ 777 /* Number of outstanding calls to pungetc. */
782 int unget; 778 int unget;
@@ -801,11 +797,7 @@ struct parsefile {
801 struct strpush *spfree; 797 struct strpush *spfree;
802 798
803 /* Remember last two characters for pungetc. */ 799 /* Remember last two characters for pungetc. */
804#if ENABLE_ASH_IGNORE_CR
805 int lastc[3]; /* Ignoring CRs needs more pungetc. */
806#else
807 int lastc[2]; 800 int lastc[2];
808#endif
809 801
810 /* Number of outstanding calls to pungetc. */ 802 /* Number of outstanding calls to pungetc. */
811 int unget; 803 int unget;
@@ -3611,11 +3603,7 @@ static const uint8_t syntax_index_table[] ALIGN1 = {
3611 /* 10 "\n" */ CNL_CNL_CNL_CNL, 3603 /* 10 "\n" */ CNL_CNL_CNL_CNL,
3612 /* 11 */ CWORD_CWORD_CWORD_CWORD, 3604 /* 11 */ CWORD_CWORD_CWORD_CWORD,
3613 /* 12 */ CWORD_CWORD_CWORD_CWORD, 3605 /* 12 */ CWORD_CWORD_CWORD_CWORD,
3614#if ENABLE_ASH_IGNORE_CR
3615 /* 13 */ CSPCL_CWORD_CWORD_CWORD,
3616#else
3617 /* 13 */ CWORD_CWORD_CWORD_CWORD, 3606 /* 13 */ CWORD_CWORD_CWORD_CWORD,
3618#endif
3619 /* 14 */ CWORD_CWORD_CWORD_CWORD, 3607 /* 14 */ CWORD_CWORD_CWORD_CWORD,
3620 /* 15 */ CWORD_CWORD_CWORD_CWORD, 3608 /* 15 */ CWORD_CWORD_CWORD_CWORD,
3621 /* 16 */ CWORD_CWORD_CWORD_CWORD, 3609 /* 16 */ CWORD_CWORD_CWORD_CWORD,
@@ -11895,9 +11883,7 @@ preadbuffer(void)
11895 more--; 11883 more--;
11896 11884
11897 c = *q; 11885 c = *q;
11898 /* Remove CR from input buffer as an alternative to ASH_IGNORE_CR. */ 11886 if (c == '\0' || (ENABLE_PLATFORM_MINGW32 && c == '\r')) {
11899 if (c == '\0' || (c == '\r' &&
11900 ENABLE_PLATFORM_MINGW32 && !ENABLE_ASH_IGNORE_CR)) {
11901 memmove(q, q + 1, more); 11887 memmove(q, q + 1, more);
11902 } else { 11888 } else {
11903 q++; 11889 q++;
@@ -11985,9 +11971,6 @@ static int __pgetc(void)
11985 else 11971 else
11986 c = preadbuffer(); 11972 c = preadbuffer();
11987 11973
11988#if ENABLE_ASH_IGNORE_CR
11989 g_parsefile->lastc[2] = g_parsefile->lastc[1];
11990#endif
11991 g_parsefile->lastc[1] = g_parsefile->lastc[0]; 11974 g_parsefile->lastc[1] = g_parsefile->lastc[0];
11992 g_parsefile->lastc[0] = c; 11975 g_parsefile->lastc[0] = c;
11993 11976
@@ -12025,24 +12008,11 @@ pgetc_eatbnl(void)
12025 int c; 12008 int c;
12026 12009
12027 while ((c = pgetc()) == '\\') { 12010 while ((c = pgetc()) == '\\') {
12028#if !ENABLE_ASH_IGNORE_CR
12029 if (pgetc() != '\n') { 12011 if (pgetc() != '\n') {
12030 pungetc(); 12012 pungetc();
12031 break; 12013 break;
12032 } 12014 }
12033#else 12015
12034 int c2 = pgetc();
12035 if (c2 == '\r') {
12036 if (pgetc() == '\n')
12037 goto eatbnl;
12038 pungetc();
12039 }
12040 if (c2 != '\n') {
12041 pungetc();
12042 break;
12043 }
12044 eatbnl:
12045#endif
12046 nlprompt(); 12016 nlprompt();
12047 } 12017 }
12048 12018
@@ -13705,7 +13675,7 @@ checkend: {
13705 c = pgetc(); 13675 c = pgetc();
13706 } 13676 }
13707 13677
13708 if (c == '\n' || c == PEOF || (ENABLE_ASH_IGNORE_CR && c == '\r')) { 13678 if (c == '\n' || c == PEOF) {
13709 c = PEOF; 13679 c = PEOF;
13710 if (trap_depth == 0) 13680 if (trap_depth == 0)
13711 g_parsefile->linno++; 13681 g_parsefile->linno++;
@@ -14181,7 +14151,7 @@ xxreadtoken(void)
14181 setprompt_if(needprompt, 2); 14151 setprompt_if(needprompt, 2);
14182 for (;;) { /* until token or start of word found */ 14152 for (;;) { /* until token or start of word found */
14183 c = pgetc_eatbnl(); 14153 c = pgetc_eatbnl();
14184 if (c == ' ' || c == '\t' || (ENABLE_ASH_IGNORE_CR && c == '\r')) 14154 if (c == ' ' || c == '\t')
14185 continue; 14155 continue;
14186 14156
14187 if (c == '#') { 14157 if (c == '#') {