struct nnot nnot;
};
+/*
+ * NODE_EOF is returned by parsecmd when it encounters an end of file.
+ * It must be distinct from NULL.
+ */
+#define NODE_EOF ((union node *) -1L)
+
struct nodelist {
struct nodelist *next;
union node *n;
return;
indent(ind, pfx, fp);
+
+ if (n == NODE_EOF) {
+ fputs("<EOF>", fp);
+ return;
+ }
+
switch (n->type) {
case NSEMI:
s = "; ";
static struct nodelist *backquotelist;
static union node *redirnode;
static struct heredoc *heredoc;
-/*
- * NEOF is returned by parsecmd when it encounters an end of file. It
- * must be distinct from NULL, so we use the address of a variable that
- * happens to be handy.
- */
-#define NEOF ((union node *)&tokpushback)
/*
* Called when an unexpected token is read during the parse. The argument
}
/*
- * Read and parse a command. Returns NEOF on end of file. (NULL is a
- * valid parse tree indicating a blank line.)
+ * Read and parse a command. Returns NODE_EOF on end of file.
+ * (NULL is a valid parse tree indicating a blank line.)
*/
static union node *
parsecmd(int interact)
needprompt = 0;
t = readtoken();
if (t == TEOF)
- return NEOF;
+ return NODE_EOF;
if (t == TNL)
return NULL;
tokpushback = 1;
setstackmark(&smark);
skip = 0;
- while ((n = parsecmd(0)) != NEOF) {
+ while ((n = parsecmd(0)) != NODE_EOF) {
evaltree(n, 0);
popstackmark(&smark);
skip = evalskip;
}
n = parsecmd(inter);
#if DEBUG > 2
- if (debug && (n != NEOF))
+ if (debug && (n != NODE_EOF))
showtree(n);
#endif
- if (n == NEOF) {
+ if (n == NODE_EOF) {
if (!top || numeof >= 50)
break;
if (!stoppedjobs()) {