From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16991 invoked by alias); 25 Jul 2015 20:30:27 -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: 35909 Received: (qmail 19419 invoked from network); 25 Jul 2015 20:30:21 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.0 X-Originating-IP: [80.3.228.158] X-Spam: 0 X-Authority: v=2.1 cv=TNS4MARa c=1 sm=1 tr=0 a=P+FLVI8RzFchTbbqTxIDRw==:117 a=P+FLVI8RzFchTbbqTxIDRw==:17 a=q_dBH0nAAAAA:8 a=NLZqzBF-AAAA:8 a=kj9zAlcOel0A:10 a=sJHWTmtfAAAA:8 a=am4dHIrw11YHjwgognkA:9 a=CjuIK1q_8ugA:10 Date: Sat, 25 Jul 2015 21:30:16 +0100 From: Peter Stephenson To: Zsh hackers list Subject: Re: [Pkg-zsh-devel] Bug#793168: zsh: expand-substitution-on-TAB broke for $(()) in 5.0.8 [origin: adi@hexapodia.org] Message-ID: <20150725213016.5578c764@ntlworld.com> In-Reply-To: <20150725201509.42d34c1d@ntlworld.com> References: <20150725170340.GY2433@sym.noone.org> <20150725201509.42d34c1d@ntlworld.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 25 Jul 2015 20:15:09 +0100 Peter Stephenson wrote: > On Sat, 25 Jul 2015 19:03:41 +0200 > Axel Beckert wrote: > > with zsh 5.0.7 and earlier versions, if I type $((5*8)) and then hit TAB, > > the expression is replaced with its evaluation ("40" in this case). The > > same feature works with many different substitutions. > > > > as of 5.0.8 TAB-substituting does not work with $(()) anymore. > > > > It does still work right with "${VAR}" and "$[5+8]". > I think the patch below fixes the expand-or-complete case. > > The _expand case is in shell code. The difference apparently > comes from the fact that in the new code $(( ... )) gets > tokenised such that the outer parentheses become Inparmath > and Outparmath, while the inner parentheses don't get tokenised. This fixes the standard quoting code, which is used by completion in a slightly non-standard (surprised?) way, with tokens still present in the string, so we can detect the math expression and avoid quoting it further. _expand now works. This is evidently not how $[...] gets handled, but as we have syntactic markers in the present case we might as well make use of them. pws diff --git a/Src/utils.c b/Src/utils.c index 0acab88..f7aaaed 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -5551,7 +5551,25 @@ quotestring(const char *s, char **e, int instring) /* Needs to be passed straight through. */ if (dobackslash) *v++ = '\\'; - *v++ = *u++; + if (*u == Inparmath) { + /* + * Already syntactically quoted: don't + * add more. + */ + int inmath = 1; + *v++ = *u++; + for (;;) { + char uc = *u; + *v++ = *u++; + if (uc == '\0') + break; + else if (uc == Outparmath && !--inmath) + break; + else if (uc == Inparmath) + ++inmath; + } + } else + *v++ = *u++; continue; }