All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] input: Remove special case for unget EOF
@ 2021-09-05  8:36 Ron Yorston
  0 siblings, 0 replies; only message in thread
From: Ron Yorston @ 2021-09-05  8:36 UTC (permalink / raw)
  To: dash

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@frippery.org>
---
 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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-05  8:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-05  8:36 [PATCH] input: Remove special case for unget EOF Ron Yorston

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.