Herbert Xu wrote:
> OK, what about this patch?
Neat. Let's see:
> --- a/src/parser.c
> +++ b/src/parser.c
[...]
> @@ -210,6 +210,7 @@ list(int nlflag)
> parseheredoc();
> else
> pungetc(); /* push back EOF on
> input */
> + tokpushback++;
> return n1;
> default:
> if (nlflag == 1)
This means to push back the TEOF instead of calling pgetc again and
again. Should be safe.
By the way, is the pungetc() call needed? I tried to provoke
misbehavior using here documents and reading from the terminal but
didn't manage to come up with a relevant scenario.
> --- a/src/parser.h
> +++ b/src/parser.h
> @@ -34,6 +34,8 @@
> * @(#)parser.h 8.3 (Berkeley) 5/4/95
> */
>
> +#include "token.h"
mksyntax #include-s parser.h, so after a "make clean":
gcc -include ../config.h -DBSD=1 -DSHELL -DIFS_BROKEN -g -Os -Wall -o
mksyntax mksyntax.c
In file included from mksyntax.c:43:0:
parser.h:37:19: fatal error: token.h: No such file or directory
The following (on top) fixes it here.
---
src/parser.c | 1 +
src/parser.h | 11 +++++++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/parser.c b/src/parser.c
index 6de27629..9c0ef606 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -40,6 +40,7 @@
#include "shell.h"
#include "parser.h"
+#include "token.h"
#include "nodes.h"
#include "expand.h" /* defines rmescapes() */
#include "exec.h" /* defines find_builtin() */
diff --git a/src/parser.h b/src/parser.h
index 2875cce6..8735890e 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -34,8 +34,6 @@
* @(#)parser.h 8.3 (Berkeley) 5/4/95
*/
-#include "token.h"
-
/* control characters in argument strings */
#define CTL_FIRST -127 /* first 'special' character */
#define CTLESC -127 /* escape next character */
@@ -69,6 +67,15 @@
#define CHKNL 0x4
#define CHKEOFMARK 0x8
+/*
+ * TEOF is the eof-of-file token defined in token.h. To avoid
+ * circular dependencies (we are used by mksyntax.c which generates
+ * token.h), repeat the definition here. Good compilers will check
+ * that this definition matches the one from token.h when processing
+ * files such as parser.c that #include both.
+ */
+#define TEOF 0
+
/*
* NEOF is returned by parsecmd when it encounters an end of file. It
--
1.7.6
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html