From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21490 invoked by alias); 16 Jan 2015 20:05:37 -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: 34313 Received: (qmail 25525 invoked from network); 16 Jan 2015 20:05:34 -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: [86.6.153.127] X-Spam: 0 X-Authority: v=2.1 cv=RcseCjdv c=1 sm=1 tr=0 a=39NrsSuza2clQiZR/7fYWQ==:117 a=39NrsSuza2clQiZR/7fYWQ==:17 a=kj9zAlcOel0A:10 a=NLZqzBF-AAAA:8 a=q2GGsy2AAAAA:8 a=_njdrEPKaFGfqeoujFwA:9 a=CjuIK1q_8ugA:10 Date: Fri, 16 Jan 2015 20:05:27 +0000 From: Peter Stephenson To: Zsh hackers list Subject: Re: Crash when capturing command output in completion Message-ID: <20150116200527.5bc0f308@ntlworld.com> In-Reply-To: References: <150115135356.ZM23582@torch.brasslantern.com> <150115162748.ZM23670@torch.brasslantern.com> <150115204336.ZM23779@torch.brasslantern.com> <150115212036.ZM23929@torch.brasslantern.com> <20150116094436.7803b467@pwslap01u.europe.root.pri> <20150116125712.3ef52e96@pwslap01u.europe.root.pri> <150116081843.ZM26927@torch.brasslantern.com> <20150116180400.6be0d82e@ntlworld.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 16 Jan 2015 11:16:28 -0800 Bart Schaefer wrote: > However, Ray's history recall problem DOES happen to me on MacOS ... start > from zsh -f and setopt histreduceblanks to see it. That explains that... You'd also have seen it when trying to extract words from the history. I wonder how many oddities are left... diff --git a/Src/hist.c b/Src/hist.c index 1c5d045..c77b5dd 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -134,6 +134,8 @@ mod_export int hist_skip_flags; /* Bits of histactive variable */ #define HA_ACTIVE (1<<0) /* History mechanism is active */ #define HA_NOINC (1<<1) /* Don't store, curhist not incremented */ +#define HA_INWORD (1<<2) /* We're inside a word, don't add + start and end markers */ /* Array of word beginnings and endings in current history line. */ @@ -299,6 +301,22 @@ hist_context_restore(const struct hist_stack *hs, int toplevel) cmdsp = hs->csp; } +/* + * Mark that the current level of history is or is not + * within a word, whatever turns up. This is used for nested + * parsing of substitutions. + */ + +/**/ +void +hist_in_word(int yesno) +{ + if (yesno) + histactive |= HA_INWORD; + else + histactive &= ~HA_INWORD; +} + /* restore history context */ /* add a character to the current history word */ @@ -1496,7 +1514,7 @@ int hwgetword = -1; void ihwbegin(int offset) { - if (stophist == 2) + if (stophist == 2 || (histactive & HA_INWORD)) return; if (chwordpos%2) chwordpos--; /* make sure we're on a word start, not end */ @@ -1516,7 +1534,7 @@ ihwbegin(int offset) void ihwend(void) { - if (stophist == 2) + if (stophist == 2 || (histactive & HA_INWORD)) return; if (chwordpos%2 && chline) { /* end of word reached and we've already begun a word */ diff --git a/Src/lex.c b/Src/lex.c index 96da1cb..6d45c70 100644 --- a/Src/lex.c +++ b/Src/lex.c @@ -1922,6 +1922,7 @@ skipcomm(void) new_lexbuf = lexbuf; zcontext_save_partial(ZCONTEXT_LEX|ZCONTEXT_PARSE); + hist_in_word(1); } else { /* * Set up for nested command subsitution, however @@ -1992,6 +1993,7 @@ skipcomm(void) tokstr = new_tokstr; lexbuf = new_lexbuf; lexstop = new_lexstop; + hist_in_word(0); } if (!lexstop) -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/