diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/shell/ash.c b/shell/ash.c index 3524d046e..152b3b46a 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -10826,9 +10826,7 @@ preadfd(void) | |||
10826 | * Refill the input buffer and return the next input character: | 10826 | * Refill the input buffer and return the next input character: |
10827 | * | 10827 | * |
10828 | * 1) If a string was pushed back on the input, pop it; | 10828 | * 1) If a string was pushed back on the input, pop it; |
10829 | * 2) If an EOF was pushed back (g_parsefile->left_in_line < -BIGNUM) | 10829 | * 2) If we are reading from a string we can't refill the buffer, return EOF. |
10830 | * or we are reading from a string so we can't refill the buffer, | ||
10831 | * return EOF. | ||
10832 | * 3) If there is more stuff in this buffer, use it else call read to fill it. | 10830 | * 3) If there is more stuff in this buffer, use it else call read to fill it. |
10833 | * 4) Process input up to the next newline, deleting nul characters. | 10831 | * 4) Process input up to the next newline, deleting nul characters. |
10834 | */ | 10832 | */ |
@@ -10845,21 +10843,9 @@ preadbuffer(void) | |||
10845 | popstring(); | 10843 | popstring(); |
10846 | return __pgetc(); | 10844 | return __pgetc(); |
10847 | } | 10845 | } |
10848 | /* on both branches above g_parsefile->left_in_line < 0. | ||
10849 | * "pgetc" needs refilling. | ||
10850 | */ | ||
10851 | 10846 | ||
10852 | /* -90 is our -BIGNUM. Below we use -99 to mark "EOF on read", | 10847 | if (g_parsefile->buf == NULL) { |
10853 | * pungetc() may increment it a few times. | ||
10854 | * Assuming it won't increment it to less than -90. | ||
10855 | */ | ||
10856 | if (g_parsefile->left_in_line < -90 || g_parsefile->buf == NULL) { | ||
10857 | pgetc_debug("preadbuffer PEOF1"); | 10848 | pgetc_debug("preadbuffer PEOF1"); |
10858 | /* even in failure keep left_in_line and next_to_pgetc | ||
10859 | * in lock step, for correct multi-layer pungetc. | ||
10860 | * left_in_line was decremented before preadbuffer(), | ||
10861 | * must inc next_to_pgetc: */ | ||
10862 | g_parsefile->next_to_pgetc++; | ||
10863 | return PEOF; | 10849 | return PEOF; |
10864 | } | 10850 | } |
10865 | 10851 | ||
@@ -10869,10 +10855,8 @@ preadbuffer(void) | |||
10869 | again: | 10855 | again: |
10870 | more = preadfd(); | 10856 | more = preadfd(); |
10871 | if (more <= 0) { | 10857 | if (more <= 0) { |
10872 | /* don't try reading again */ | 10858 | g_parsefile->left_in_buffer = g_parsefile->left_in_line = 0; |
10873 | g_parsefile->left_in_line = -99; | ||
10874 | pgetc_debug("preadbuffer PEOF2"); | 10859 | pgetc_debug("preadbuffer PEOF2"); |
10875 | g_parsefile->next_to_pgetc++; | ||
10876 | return PEOF; | 10860 | return PEOF; |
10877 | } | 10861 | } |
10878 | } | 10862 | } |