summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Src/hist.c6
-rw-r--r--Src/lex.c2
3 files changed, 13 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 31dee6dbe..ecd99332b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-03-29  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 34817: Src/hist.c, Src/lex.c: catch some errors earlier when
+	handling history to avoid knock-on errors and doing too much
+	processing.
+
 2015-03-29  Theo Buehler  <theo@math.ethz.ch>
 
 	* 34792: Src/Modules/langinfo.c: langinfo: Fix pointer type
diff --git a/Src/hist.c b/Src/hist.c
index 990e609df..185d0a0d8 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -2604,6 +2604,8 @@ readhistfile(char *fn, int err, int readflags)
 	     */
 	    if (uselex || remeta)
 		freeheap();
+	    if (errflag & ERRFLAG_INT)
+		break;
 	}
 	if (start && readflags & HFILE_USE_OPTIONS) {
 	    zsfree(lasthist.text);
@@ -3331,7 +3333,7 @@ bufferwords(LinkList list, char *buf, int *index, int flags)
 	    got = 1;
 	    cur = num - 1;
 	}
-    } while (tok != ENDINPUT && tok != LEXERR);
+    } while (tok != ENDINPUT && tok != LEXERR && !(errflag & ERRFLAG_INT));
     if (buf && tok == LEXERR && tokstr && *tokstr) {
 	int plen;
 	untokenize((p = dupstring(tokstr)));
@@ -3408,6 +3410,8 @@ histsplitwords(char *lineptr, short **wordsp, int *nwordsp, int *nwordposp,
 
 	wordlist = bufferwords(NULL, lineptr, NULL,
 			       LEXFLAGS_COMMENTS_KEEP);
+	if (errflag)
+	    return;
 	nwords_max = 2 * countlinknodes(wordlist);
 	if (nwords_max > nwords) {
 	    *nwordsp = nwords = nwords_max;
diff --git a/Src/lex.c b/Src/lex.c
index 5fed2be49..184a54b0b 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1345,6 +1345,8 @@ gettokstr(int c, int sub)
 	    break;
     }
   brk:
+    if (errflag)
+	return LEXERR;
     hungetc(c);
     if (unmatched)
 	zerr("unmatched %c", unmatched);