From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20692 invoked by alias); 31 Dec 2015 22:12:11 -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: 37469 Received: (qmail 11999 invoked from network); 31 Dec 2015 22:12:09 -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=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=pZWKwX08Snwjd7CqQHcFzJ6BL9bjOGZykANw67X3q18=; b=cZovOnXkHQ0dnTrV7/IZK28qsSoavbaVDLkKySyKju+QA0nmCT0JjrKHRPqAAcaMZo ar+OldKsMOC+cUBpht0lPLSUfqILx90SdjMPgDOd9JNKm4B9o3hPNYlhfcl49HoiNyeF shiL0EMVBD64xk8hE0BZcGGiCVtKQNP7IdDE+H8B1j9CoX2G1NB7A3GkrF8QFpFzFFXp uyStb1TUZkGbLChfEPTEeEdEks641gUhP2pjj7UOMcul7VAVXFY/gonEEns2V3OZ0HYZ su2J+NTGymxBXusujfOpDDNvV5wVD5VO9J0l8maonD7E3ZmBjHBgbWCG1GbOLINLPEoo GN7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=pZWKwX08Snwjd7CqQHcFzJ6BL9bjOGZykANw67X3q18=; b=Rvp1om73dtuY6Qm34+FGv3EqDxAyJmQgQLUnsxyEfcDPQXjn2QnKP02nSSnNYOJDPN eILh/66fW/jVqyf5P08cO6kNA8xFdNc+wctUUh/7TjCOQz2ezybMkTSgpk/vhKc4nQhq PRAiPOEPqmTb7547EssrB+p8pGHIK6nJWCo1iRl9OTC/bjRoVp0A6Xb057wzYvhfyI2g ioWCk5qyb07yOKeqiWIYA8VX+7odBMxZ1a3ScBw78OgDCVthV8jNKOFcuImjhRQ11vlK TzePFC+IoAagdafj0B9hyb8PDJEawKU+D8K66kwEPyAFbD5ugOyAoin8lUdxS506r5nv yfjg== X-Gm-Message-State: ALoCoQmnIkL8isNkjK6PBQqoeZJXccyZDaOw0eCzuGo8g0qeQ4t1fCFO4NChTYoAx8U3vjZMXArNrH01R24euWjkgd1aFDZWXA== X-Received: by 10.98.73.7 with SMTP id w7mr102820354pfa.158.1451599926311; Thu, 31 Dec 2015 14:12:06 -0800 (PST) From: Bart Schaefer Message-Id: <151231141207.ZM11115@torch.brasslantern.com> Date: Thu, 31 Dec 2015 14:12:07 -0800 In-Reply-To: <151231113107.ZM1241@torch.brasslantern.com> Comments: In reply to Bart Schaefer "Multi-line conditionals (Re: Sourcing bash completion files)" (Dec 31, 11:31am) References: <20151230232254.GC12070@drscott.swordarmor.fr> <151230173658.ZM9725@torch.brasslantern.com> <5684E4B2.8000100@gmx.com> <151231113107.ZM1241@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Multi-line conditionals (Re: Sourcing bash completion files) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Dec 31, 11:31am, Bart Schaefer wrote: } } There are a number of places where } } while (tok == SEPER) } condlex(); } } appears, but apparently not enough of them. Also it's a bit tricky } because of course [ ... ] mustn't span lines. Also it should be an error to use ';' as the separator here. This patch applies on top of the previous one. There probably ought to be (and perhaps is) a cleaner way to handle this than testing *zshlextext, because we did know at one point that tok == NEWLINE, but that was clobbered by assigning tok = SEPER and tokstr has never been set. diff --git a/Src/parse.c b/Src/parse.c index 6949b13..4829e3a 100644 --- a/Src/parse.c +++ b/Src/parse.c @@ -2252,6 +2252,8 @@ void (*condlex) _((void)) = zshlex; * cond : cond_1 { SEPER } [ DBAR { SEPER } cond ] */ +#define COND_SEP() (tok == SEPER && condlex != testlex && *zshlextext != ';') + /**/ static int par_cond(void) @@ -2259,11 +2261,11 @@ par_cond(void) int p = ecused, r; r = par_cond_1(); - while (tok == SEPER) + while (COND_SEP()) condlex(); if (tok == DBAR) { condlex(); - while (tok == SEPER) + while (COND_SEP()) condlex(); ecispace(p, 1); par_cond(); @@ -2284,11 +2286,11 @@ par_cond_1(void) int r, p = ecused; r = par_cond_2(); - while (tok == SEPER) + while (COND_SEP()) condlex(); if (tok == DAMPER) { condlex(); - while (tok == SEPER) + while (COND_SEP()) condlex(); ecispace(p, 1); par_cond_1(); @@ -2349,7 +2351,7 @@ par_cond_2(void) * or any other time there are at least two arguments. */ } else - while (tok == SEPER) + while (COND_SEP()) condlex(); if (tok == BANG) { /* @@ -2368,10 +2370,10 @@ par_cond_2(void) int r; condlex(); - while (tok == SEPER) + while (COND_SEP()) condlex(); r = par_cond(); - while (tok == SEPER) + while (COND_SEP()) condlex(); if (tok != OUTPAR) YYERROR(ecused); @@ -2387,7 +2389,7 @@ par_cond_2(void) /* Check first argument for [[ STRING ]] re-interpretation */ if (s1 /* tok != DOUTBRACK && tok != DAMPER && tok != DBAR */ && tok != LEXERR && (!dble || n_testargs)) { - do condlex(); while (tok == SEPER && condlex != testlex); + do condlex(); while (COND_SEP()); return par_cond_double(dupstring("-n"), s1); } else YYERROR(ecused); @@ -2401,15 +2403,15 @@ par_cond_2(void) */ tok = STRING; } else - while (tok == SEPER && condlex != testlex) + while (COND_SEP()) condlex(); if (tok == INANG || tok == OUTANG) { enum lextok xtok = tok; - do condlex(); while (tok == SEPER && condlex != testlex); + do condlex(); while (COND_SEP()); if (tok != STRING) YYERROR(ecused); s3 = tokstr; - do condlex(); while (tok == SEPER && condlex != testlex); + do condlex(); while (COND_SEP()); ecadd(WCB_COND((xtok == INANG ? COND_STRLT : COND_STRGTR), 0)); ecstr(s1); ecstr(s3); @@ -2432,11 +2434,11 @@ par_cond_2(void) if (!n_testargs) dble = (s2 && *s2 == '-' && !s2[2]); incond++; /* parentheses do globbing */ - do condlex(); while (tok == SEPER && condlex != testlex); + do condlex(); while (COND_SEP()); incond--; /* parentheses do grouping */ if (tok == STRING && !dble) { s3 = tokstr; - do condlex(); while (tok == SEPER && condlex != testlex); + do condlex(); while (COND_SEP()); if (tok == STRING) { LinkList l = newlinklist(); @@ -2445,7 +2447,7 @@ par_cond_2(void) while (tok == STRING) { addlinknode(l, tokstr); - do condlex(); while (tok == SEPER && condlex != testlex); + do condlex(); while (COND_SEP()); } return par_cond_multi(s1, l); } else -- Barton E. Schaefer