about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2001-11-21 17:03:56 +0000
committerBart Schaefer <barts@users.sourceforge.net>2001-11-21 17:03:56 +0000
commit01ce2a758cbccbce4b7489510f7cd3e4abd8b7f6 (patch)
tree93d63a7fe59d4706998385fc53a789b88a3a502d
parent7c30945e0840e59c6b889093baa8596f3c8ccd56 (diff)
downloadzsh-01ce2a758cbccbce4b7489510f7cd3e4abd8b7f6.tar.gz
zsh-01ce2a758cbccbce4b7489510f7cd3e4abd8b7f6.tar.xz
zsh-01ce2a758cbccbce4b7489510f7cd3e4abd8b7f6.zip
16249: Clear here-documents on parse error.
-rw-r--r--ChangeLog5
-rw-r--r--Src/parse.c25
2 files changed, 27 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 1487667a1..909c72568 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2001-11-21  Bart Schaefer  <schaefer@zsh.org>
+
+	* Sven: 16249: Src/parse.c: Clear pending here-documents upon a
+	parse error.
+
 2001-11-18  Clint Adams  <clint@zsh.org>
 
 	* 16264: Completion/Debian/Command/_dput:
diff --git a/Src/parse.c b/Src/parse.c
index cec3311dd..fefbbfe32 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -420,6 +420,18 @@ empty_eprog(Eprog p)
     return (!p || !p->prog || *p->prog == WCB_END());
 }
 
+static void
+clear_hdocs()
+{
+    struct heredocs *p, *n;
+
+    for (p = hdocs; p; p = n) {
+        n = p->next;
+        zfree(p, sizeof(struct heredocs));
+    }
+    hdocs = NULL;
+}
+
 /*
  * event	: ENDINPUT
  *			| SEPER
@@ -435,7 +447,12 @@ parse_event(void)
     aliasspaceflag = 0;
     yylex();
     init_parse();
-    return ((par_event()) ? bld_eprog() : NULL);
+
+    if (!par_event()) {
+        clear_hdocs();
+        return NULL;
+    }
+    return bld_eprog();
 }
 
 /**/
@@ -509,6 +526,7 @@ parse_list(void)
     init_parse();
     par_list(&c);
     if (tok != ENDINPUT) {
+        clear_hdocs();
 	tok = LEXERR;
 	yyerror(0);
 	return NULL;
@@ -522,9 +540,10 @@ parse_cond(void)
 {
     init_parse();
 
-    if (!par_cond())
+    if (!par_cond()) {
+        clear_hdocs();
 	return NULL;
-
+    }
     return bld_eprog();
 }