Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
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=bdUjKkXwULd8mULSRO/z9sbk90CFYBII8h1YJLhwfws=;
        b=U/STMiUvSbBP7N8Lbb3U0kLnJ3QvUCEWWgIK+HcU7Vh0Lcwfo1fmKIbBrtLh2TLO9e
         PLNDF98CpRlHQOeatOljnMloCLyZm+vXsfaJ37EB/JWHt6BjWTUg73UCdfrHwTAJ+u5L
         8OlZGkH/rZ6pC6nw4im+myc0zlvAAoL20p9q5ZviIiS42N4WqDsScFw8SkGPefW/Oiil
         KBKbweHv3bV8sEWCuGkSo9g3RAMRUmk65rZqB5jwlHdZ+temsgnTsUMVwQ3Y/Lgg5pWJ
         ocEeImdQzPFL1I46MGISoagilHJVvjwflJB52TbCx/00aAItQl3PtyMSqY+l6oX+ugRY
         qSOw==
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=bdUjKkXwULd8mULSRO/z9sbk90CFYBII8h1YJLhwfws=;
        b=HZTh8L/ahr1SCbm3HkaiH8PaJgirVuUVaSB9opI0W1fB8p00Z9NEPldwU//Igs5iFq
         Kn1fnMzriS3Ih1xb99xIa8/QJS7bCz9nAkZjgWXV+9ffY6QyeL7C3lK2EJxKPsDZBBe6
         oM2sdf+IRsXkIz7/s0HJCDY9SIEjaEC/mD76n1mS+kBBjZmbJVp1TW77OJ8+cDWBVmGE
         gbCnv9OVAQyiQwEj6dBftTxHqNeXfbxu0HudC5pY/bQrSOgBOxYIWwoW4VnLySHGFkwy
         S87My4mNM52psBS4O6rPYVptCjU2PkZoF8QTVqopVsOUeVGHtyh4snfsqvBgZv9NUoFd
         Z/Qg==
X-Gm-Message-State: ALoCoQnMIji8HkmBC9pgEZLuyIgvBePRmEry+2FT2aAPWhtxorYTvK7MxiEUo27yexYB8x1zhUEO9WWv372WxXBdp4eseU27xg==
X-Received: by 10.98.68.85 with SMTP id r82mr46364159pfa.143.1451590267335;
        Thu, 31 Dec 2015 11:31:07 -0800 (PST)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <151231113107.ZM1241@torch.brasslantern.com>
Date: Thu, 31 Dec 2015 11:31:07 -0800
In-Reply-To: <5684E4B2.8000100@gmx.com>
Comments: In reply to Eric Cook <llua@gmx.com>
        "Re: Sourcing bash completion files" (Dec 31,  3:17am)
References: <20151230232254.GC12070@drscott.swordarmor.fr> 
	<151230173658.ZM9725@torch.brasslantern.com> 
	<5684E4B2.8000100@gmx.com>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: zsh-workers@zsh.org
Subject: Multi-line conditionals (Re: Sourcing bash completion files)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 37468

On Dec 31,  3:17am, Eric Cook wrote:
}
} that error is due to [[ not being able to span across lines.

Hmm, I'm relatively sure [[ is supposed to be able to span lines.
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.


diff --git a/Src/parse.c b/Src/parse.c
index 83ba396..6949b13 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -2348,7 +2348,9 @@ par_cond_2(void)
 	 * We fall through here on any non-numeric infix operator
 	 * or any other time there are at least two arguments.
 	 */
-    }
+    } else
+	while (tok == SEPER)
+	    condlex();
     if (tok == BANG) {
 	/*
 	 * In "test" compatibility mode, "! -a ..." and "! -o ..."
@@ -2385,7 +2387,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)) {
-	    condlex();
+	    do condlex(); while (tok == SEPER && condlex != testlex);
 	    return par_cond_double(dupstring("-n"), s1);
 	} else
 	    YYERROR(ecused);
@@ -2398,14 +2400,16 @@ par_cond_2(void)
 	 * checked it does have a string representation).
 	 */
 	tok = STRING;
-    }
+    } else
+	while (tok == SEPER && condlex != testlex)
+	    condlex();
     if (tok == INANG || tok == OUTANG) {
 	enum lextok xtok = tok;
-	condlex();
+	do condlex(); while (tok == SEPER && condlex != testlex);
 	if (tok != STRING)
 	    YYERROR(ecused);
 	s3 = tokstr;
-	condlex();
+	do condlex(); while (tok == SEPER && condlex != testlex);
 	ecadd(WCB_COND((xtok == INANG ? COND_STRLT : COND_STRGTR), 0));
 	ecstr(s1);
 	ecstr(s3);
@@ -2428,11 +2432,11 @@ par_cond_2(void)
     if (!n_testargs)
 	dble = (s2 && *s2 == '-' && !s2[2]);
     incond++;			/* parentheses do globbing */
-    condlex();
+    do condlex(); while (tok == SEPER && condlex != testlex);
     incond--;			/* parentheses do grouping */
     if (tok == STRING && !dble) {
 	s3 = tokstr;
-	condlex();
+	do condlex(); while (tok == SEPER && condlex != testlex);
 	if (tok == STRING) {
 	    LinkList l = newlinklist();
 
@@ -2441,7 +2445,7 @@ par_cond_2(void)
 
 	    while (tok == STRING) {
 		addlinknode(l, tokstr);
-		condlex();
+		do condlex(); while (tok == SEPER && condlex != testlex);
 	    }
 	    return par_cond_multi(s1, l);
 	} else

