From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3/2) with ESMTP id LAA27688 for ; Fri, 19 Jul 1996 11:18:22 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id VAA13435; Thu, 18 Jul 1996 21:13:17 -0400 (EDT) Resent-Date: Thu, 18 Jul 1996 21:11:29 -0400 (EDT) From: Zoltan Hidvegi Message-Id: <199607182343.BAA02057@hzoli.ppp.cs.elte.hu> Subject: Re: Bug in case stmt with '(' To: schaefer@nbn.com Date: Fri, 19 Jul 1996 01:43:26 +0200 (MET DST) Cc: segal@morgan.com, zsh-users@math.gatech.edu In-Reply-To: <9607181127.ZM13011@candle.brasslantern.com> from Bart Schaefer at "Jul 18, 96 11:27:51 am" X-Mailer: ELM [version 2.4ME+ PL17 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"JpCvU2.0.GF3.x2kxn"@euclid> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/312 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Bart Schaefer wrote: > > It seems that when a pattern in a case statement is preceded by the optional > > '(', the parser is in the wrong state when parsing the statement following > > the pattern. [...] > That means it can't look only for matching parens, but also has to look > for matching parens followed by a closing paren or vertical bar. > > I'm unsure of this patch, so the pre3 stuff is still there #ifdef OLD. > There may be a better way to deal with it. Actually the patch below is a simpler solution for that. An other advantage of that is that hgetc()/hungetc() is not used which is scientifically better since tokens should be recognized in lex.c and parse.c should only use the tokens returned by lex.c. The patch to lex.c removes an unnecessary special case for `<' in a case pattern. After that the only effect of the incasepat variable is that it disables spell checking. Zoltan *** Src/parse.c 1996/07/13 20:26:35 2.20 --- Src/parse.c 1996/07/18 23:32:54 *************** *** 502,512 **** --- 502,516 ---- break; } str = tokstr; + incasepat = 0; + incmdpos = 1; yylex(); while (tok == BAR) { char *str2; int sl = strlen(str); + incasepat = 1; + incmdpos = 0; yylex(); if (tok == OUTPAR) { str2 = ncalloc(sl + 2); *************** *** 514,519 **** --- 518,525 ---- str2[sl] = Bar; str2[sl+1] = '\0'; str = str2; + incasepat = 0; + incmdpos = 1; break; } if (tok != STRING) *************** *** 525,532 **** str = str2; yylex(); } - incasepat = 0; - incmdpos = 1; if (tok != OUTPAR) { /* POSIX allows (foo*) patterns */ char *s = str; --- 531,536 ---- *** Src/lex.c 1996/07/13 20:26:35 2.35 --- Src/lex.c 1996/07/18 23:29:53 *************** *** 496,502 **** return OUTPAR; case LX1_INANG: d = hgetc(); ! if ((!incmdpos && d == '(') || incasepat) { hungetc(d); lexstop = 0; break; --- 496,502 ---- return OUTPAR; case LX1_INANG: d = hgetc(); ! if (!incmdpos && d == '(') { hungetc(d); lexstop = 0; break;