From: Ron Yorston <rmy@frippery.org>
To: dash@vger.kernel.org
Subject: [PATCH] input: Remove special case for unget EOF
Date: Sun, 05 Sep 2021 09:36:11 +0100 [thread overview]
Message-ID: <6134817b.feb8Hlf2SOdlZPZw%rmy@frippery.org> (raw)
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
reply other threads:[~2021-09-05 8:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6134817b.feb8Hlf2SOdlZPZw%rmy@frippery.org \
--to=rmy@frippery.org \
--cc=dash@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).