@@ -157,7 +157,7 @@ static int __pgetc(void)
* Nul characters in the input are silently discarded.
*/
-int pgetc(void)
+int __attribute__((noinline)) pgetc(void)
{
struct strpush *sp = parsefile->spfree;
@@ -167,6 +167,12 @@ int pgetc(void)
return __pgetc();
}
+int pgetc_eoa(void)
+{
+ return parsefile->strpush && parsefile->nleft == -1 &&
+ parsefile->strpush->ap ? PEOA : pgetc();
+}
+
static int stdin_clear_nonblock(void)
{
int flags = fcntl(0, F_GETFL, 0);
@@ -45,6 +45,7 @@
#define PUNGETC_MAX (MB_LEN_MAX > 16 ? MB_LEN_MAX : 16)
/* PEOF (the end of file marker) is defined in syntax.h */
+#define PEOA ((PEOF) - 1)
enum {
INPUT_PUSH_FILE = 1,
@@ -102,7 +103,7 @@ extern struct parsefile *parsefile;
#define plinno (parsefile->linno)
int pgetc(void);
-int pgetc2(void);
+int pgetc_eoa(void);
void pungetc(void);
void pungetn(int);
void pushstring(char *, void *);
This reintroduces PEOA in a limited way. Instead of allowing pgetc to return it, limit it to a new function pgetc_eoa so only specific callers need to deal with PEOA. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> --- src/input.c | 8 +++++++- src/input.h | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-)