From: Jonathan Nieder <jrnieder@gmail.com>
To: dash@vger.kernel.org
Cc: Jilles Tjoelker <jilles@stack.nl>,
Drake Wilson <drake@begriffli.ch>, Reuben Thomas <rrt@sc3d.org>
Subject: [PATCH 1/4] [INPUT] Introduce preadateof predicate to check for end of input
Date: Sun, 10 Apr 2011 02:21:06 -0500 [thread overview]
Message-ID: <20110410072106.GA17649@elie> (raw)
In-Reply-To: <20110410071734.GA16736@elie>
From: Jilles Tjoelker <jilles@stack.nl>
Date: Sat, 13 Jun 2009 16:17:45 -0500
For example, this can be used to detect tail calls in the string
passed to -c.
[jn: originally from Jilles as part of FreeBSD SVN r194128]
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Could be squashed with patch 3. I split it out while considering
using the same trick in cmdloop.
src/input.c | 17 +++++++++++++++++
src/input.h | 1 +
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/src/input.c b/src/input.c
index d31c45b..39d7893 100644
--- a/src/input.c
+++ b/src/input.c
@@ -325,6 +325,23 @@ again:
}
/*
+ * Returns if we are certain we are at EOF. Does not cause any more input
+ * to be read from the outside world.
+ */
+
+int
+preadateof(void)
+{
+ if (parsenleft > 0)
+ return 0;
+ if (parsefile->strpush)
+ return 0;
+ if (parsenleft == EOF_NLEFT || parsefile->buf == NULL)
+ return 1;
+ return 0;
+}
+
+/*
* Undo the last call to pgetc. Only one character may be pushed back.
* PEOF may be pushed back.
*/
diff --git a/src/input.h b/src/input.h
index 50a7797..d123045 100644
--- a/src/input.h
+++ b/src/input.h
@@ -53,6 +53,7 @@ extern char *parsenextc; /* next character in input buffer */
int pgetc(void);
int pgetc2(void);
int preadbuffer(void);
+int preadateof(void);
void pungetc(void);
void pushstring(char *, void *);
void popstring(void);
--
1.7.5.rc0
next prev parent reply other threads:[~2011-04-10 7:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-10 7:18 [PATCH/RFC dash 0/4] Avoid a fork before running last command given to -c Jonathan Nieder
2011-04-10 7:21 ` Jonathan Nieder [this message]
2011-04-10 7:22 ` [PATCH 2/4] [EVAL] Make eval flags public Jonathan Nieder
2011-04-10 7:35 ` [PATCH 3/4] [EVAL] Take advantage of EV_EXIT in evalstring Jonathan Nieder
2011-04-10 7:36 ` [PATCH 4/4] [MAIN] Optimize dash -c "command" to avoid a fork Jonathan Nieder
2011-07-07 3:48 ` Herbert Xu
2011-07-07 4:27 ` Jonathan Nieder
2011-07-07 4:57 ` Herbert Xu
2011-07-07 5:56 ` Herbert Xu
2011-07-07 7:48 ` Jonathan Nieder
2011-07-07 8:22 ` Herbert Xu
2011-07-07 8:37 ` Jonathan Nieder
2011-07-07 8:39 ` Herbert Xu
2011-04-10 7:38 ` [PATCH 5/4] [EVAL] Remove unused EV_BACKCMD flag Jonathan Nieder
2011-07-07 3:56 ` Herbert Xu
2011-04-15 13:07 ` [PATCH/RFC dash 0/4] Avoid a fork before running last command given to -c Herbert Xu
2011-04-17 22:13 ` Jilles Tjoelker
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=20110410072106.GA17649@elie \
--to=jrnieder@gmail.com \
--cc=dash@vger.kernel.org \
--cc=drake@begriffli.ch \
--cc=jilles@stack.nl \
--cc=rrt@sc3d.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 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.