From f1c702f2a4159409b27b9576999614a69a51987d Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 29 Mar 2015 19:47:01 +0100 Subject: 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. --- Src/hist.c | 6 +++++- Src/lex.c | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'Src') 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); -- cgit 1.4.1