From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7345 invoked by alias); 29 Mar 2015 18:38:30 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34817 Received: (qmail 17302 invoked from network); 29 Mar 2015 18:38:16 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Originating-IP: [80.3.228.158] X-Spam: 0 X-Authority: v=2.1 cv=Ku/D2AmN c=1 sm=1 tr=0 a=P+FLVI8RzFchTbbqTxIDRw==:117 a=P+FLVI8RzFchTbbqTxIDRw==:17 a=kj9zAlcOel0A:10 a=NLZqzBF-AAAA:8 a=hD80L64hAAAA:8 a=pGLkceISAAAA:8 a=oFGAibjKxieM91jmnJ4A:9 a=CjuIK1q_8ugA:10 Date: Sun, 29 Mar 2015 19:38:04 +0100 From: Peter Stephenson To: Zsh Hackers' List Subject: Re: PATCH: Removing aliases from history, 2015 style Message-ID: <20150329193804.300569a3@ntlworld.com> In-Reply-To: <20150327100648.7f8d5aaa@pwslap01u.europe.root.pri> References: <20150319105716.620cd931@pwslap01u.europe.root.pri> <20150319125351.1e270c2d@pwslap01u.europe.root.pri> <20150320105703.2754b6af@pwslap01u.europe.root.pri> <150320090420.ZM21908@torch.brasslantern.com> <20150322183556.1fa0f143@ntlworld.com> <150322162235.ZM1728@torch.brasslantern.com> <20150323213426.21fd79c8@ntlworld.com> <20150325154853.7efc21d0@pwslap01u.europe.root.pri> <20150325175706.06cb1a8f@pwslap01u.europe.root.pri> <20150327100648.7f8d5aaa@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 27 Mar 2015 10:06:48 +0000 Peter Stephenson wrote: > On Wed, 25 Mar 2015 19:42:22 +0100 > Mikael Magnusson wrote: > > FWIW, I don't use !-expansion at all, but who knows, maybe that'll > > make it more likely I find the corner case. > > You do use HISTLEXWORDS, however, so you might notice the following: > it looks like I've managed to make that work less well when > interrupted. If I ^C during the history read I get > > > ^CWarning: backing up wrong character. >... > hist.c:3524: bad wordsplit reading history: ((print foo); print bar) >... Various changes here. Backing up the wrong character is because sometimes we "goto brk" when there's an error; if there is, it looks benign to return LEXERR at that point. Note we do this from lots of places and generally set "peek = LEXERR" but don't worry about fixing up "c" --- but clearly "c" has become irrelevant. So I didn't try to muck around fixing up "c" in the case in question, which I think is a return from cmd_or_math_sub() where we don't have a useful character. In history, if there was an error buffering words, don't try to do the word split. Those two seem to fix the specific problems above. In both cases as we were in an inner loop and depended on the previous processing being successful it seemed reasonable to be sensitive to both bits of errflag. The other two are in the history reading code. They make it more sensitive to interruption by stopping loops over words and lines in that case. Here it's specific to the interruption rather than any error. diff --git a/Src/hist.c b/Src/hist.c index 990e609..185d0a0 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 5fed2be..184a54b 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);