about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2015-03-29 19:47:01 +0100
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2015-03-29 19:47:01 +0100
commitf1c702f2a4159409b27b9576999614a69a51987d (patch)
tree947a2fef650080a52feb33e7ae359e0cdae1ed80 /Src
parentb4aa9cdc7641c6c923c1bda1c73111d80be79ba1 (diff)
downloadzsh-f1c702f2a4159409b27b9576999614a69a51987d.tar.gz
zsh-f1c702f2a4159409b27b9576999614a69a51987d.tar.xz
zsh-f1c702f2a4159409b27b9576999614a69a51987d.zip
34817: Catch some errors earlier when reading history.
Mostly for the case of an interrupt.

Don't try to process words when we know something's gone wrong.

Also abort history reading earlier on an interrupt.
Diffstat (limited to 'Src')
-rw-r--r--Src/hist.c6
-rw-r--r--Src/lex.c2
2 files changed, 7 insertions, 1 deletions
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);