Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug in case stmt with '('
- X-seq: zsh-users 312
- From: Zoltan Hidvegi <hzoli@xxxxxxxxxx>
- To: schaefer@xxxxxxx
- Subject: Re: Bug in case stmt with '('
- Date: Fri, 19 Jul 1996 01:43:26 +0200 (MET DST)
- Cc: segal@xxxxxxxxxx, zsh-users@xxxxxxxxxxxxxxx
- In-reply-to: <9607181127.ZM13011@xxxxxxxxxxxxxxxxxxxxxxx> from Bart Schaefer at "Jul 18, 96 11:27:51 am"
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;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author