Commit 17db43b5841504b694203952fb0e82246c06a97f (input: Allow two consecutive calls to pungetc) ensures that EOF is handled like any other character with respect to unget. As a result it's possible to remove the special case for unget of EOF in preadbuffer. Signed-off-by: Ron Yorston <rmy@xxxxxxxxxxxx> --- src/input.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/input.c b/src/input.c index d7c101b..ec075f5 100644 --- a/src/input.c +++ b/src/input.c @@ -58,7 +58,6 @@ #include "myhistedit.h" #endif -#define EOF_NLEFT -99 /* value of parsenleft when EOF pushed back */ #define IBUFSIZ (BUFSIZ + 1) @@ -220,9 +219,8 @@ retry: * Refill the input buffer and return the next input character: * * 1) If a string was pushed back on the input, pop it; - * 2) If an EOF was pushed back (parsenleft == EOF_NLEFT) or we are reading - * from a string so we can't refill the buffer, return EOF. - * 3) If the is more stuff in this buffer, use it else call read to fill it. + * 2) If we are reading from a string we can't refill the buffer, return EOF. + * 3) If there is more stuff in this buffer, use it else call read to fill it. * 4) Process input up to the next newline, deleting nul characters. */ @@ -239,8 +237,7 @@ static int preadbuffer(void) popstring(); return __pgetc(); } - if (unlikely(parsefile->nleft == EOF_NLEFT || - parsefile->buf == NULL)) + if (parsefile->buf == NULL) return PEOF; flushall(); @@ -248,7 +245,7 @@ static int preadbuffer(void) if (more <= 0) { again: if ((more = preadfd()) <= 0) { - parsefile->lleft = parsefile->nleft = EOF_NLEFT; + parsefile->lleft = parsefile->nleft = 0; return PEOF; } } -- 2.31.1