From: Zoltan Hidvegi <hzoli@cs.elte.hu>
To: schaefer@nbn.com
Cc: zsh-users@math.gatech.edu
Subject: Re: Bug in case stmt with '('
Date: Fri, 19 Jul 1996 18:00:37 +0200 (MET DST) [thread overview]
Message-ID: <199607191600.SAA08613@bolyai.cs.elte.hu> (raw)
In-Reply-To: <960718192358.ZM702@candle.brasslantern.com> from Bart Schaefer at "Jul 18, 96 07:23:58 pm"
> > Actually the patch below is a simpler solution for that.
>
> Is it? It handles (v|w)), but it doesn't handle this case:
>
> case v in
> (v|w)|x) gigo="case '(v|w)|x)'"
> echo $gigo;;
> *) gigo="case '*)'"
> echo $gigo;;
> esac
All right. It was late at night when I wrote that. Below is an other
attempt. It is a patch against unmodified 3_0-pre3.
> > An other
> > advantage of that is that hgetc()/hungetc() is not used which is
> > scientifically better since tokens should be recognized in lex.c
>
> Yes, I know, but there are other cases in parse.c that lookahead with
> hgetc().
hgetc/hungetc is only used in parse.c to discard the remaining line after a
parse error. It is not used for parsing. For parsing only the tokens
return by yylex() must be used.
Zoltan
*** Src/parse.c 1996/07/13 20:26:35 2.20
--- Src/parse.c 1996/07/19 15:38:54
***************
*** 502,540 ****
break;
}
str = tokstr;
! yylex();
! while (tok == BAR) {
! char *str2;
! int sl = strlen(str);
!
yylex();
if (tok == OUTPAR) {
str2 = ncalloc(sl + 2);
strcpy(str2, str);
str2[sl] = Bar;
str2[sl+1] = '\0';
str = str2;
break;
}
- if (tok != STRING)
- YYERRORV;
- str2 = ncalloc(sl + strlen(tokstr) + 2);
- strcpy(str2, str);
- str2[sl] = Bar;
- strcpy(str2 + sl + 1, tokstr);
- str = str2;
- yylex();
}
- incasepat = 0;
- incmdpos = 1;
- if (tok != OUTPAR) {
- /* POSIX allows (foo*) patterns */
- char *s = str;
-
- if (skipparens(Inpar, Outpar, &s) || *s)
- YYERRORV;
- } else
- yylex();
addlinknode(pats, str);
addlinknode(lists, par_list());
n++;
--- 502,546 ----
break;
}
str = tokstr;
! incasepat = 0;
! incmdpos = 1;
! for (;;) {
yylex();
if (tok == OUTPAR) {
+ incasepat = 0;
+ incmdpos = 1;
+ yylex();
+ break;
+ } else if (tok == BAR) {
+ char *str2;
+ int sl = strlen(str);
+
+ incasepat = 1;
+ incmdpos = 0;
str2 = ncalloc(sl + 2);
strcpy(str2, str);
str2[sl] = Bar;
str2[sl+1] = '\0';
str = str2;
+ } else if (tok == STRING) {
+ char *str2;
+ int sl = strlen(str);
+
+ if (str[sl - 1] != Bar)
+ YYERRORV;
+ str2 = ncalloc(sl + strlen(tokstr) + 1);
+ strcpy(str2, str);
+ strcpy(str2 + sl, tokstr);
+ str = str2;
+ } else {
+ /* POSIX allows (foo*) patterns */
+ char *s = str;
+
+ if (skipparens(Inpar, Outpar, &s) || *s)
+ YYERRORV;
break;
}
}
addlinknode(pats, str);
addlinknode(lists, par_list());
n++;
next prev parent reply other threads:[~1996-07-19 16:09 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-07-17 21:01 Morris M. Siegel
1996-07-18 18:27 ` Bart Schaefer
1996-07-18 23:43 ` Zoltan Hidvegi
1996-07-19 2:23 ` Bart Schaefer
1996-07-19 16:00 ` Zoltan Hidvegi [this message]
1996-07-21 22:53 ` Morris M. Siegel
1996-07-22 6:31 ` Bart Schaefer
[not found] ` <schaefer@candle.brasslantern.com>
1996-07-22 19:26 ` Morris M. Siegel
1996-07-22 19:51 ` Zoltan Hidvegi
1996-07-22 20:48 ` Morris M. Siegel
1996-07-22 21:27 ` Zefram
1996-07-22 21:56 ` Morris M. Siegel
1996-07-22 21:51 ` Bart Schaefer
1996-07-22 21:23 ` Zefram
1996-07-22 22:31 ` Morris M. Siegel
1996-07-22 23:37 ` Bart Schaefer
1996-07-24 16:07 ` Morrie is off for July 25 Morris M. Siegel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199607191600.SAA08613@bolyai.cs.elte.hu \
--to=hzoli@cs.elte.hu \
--cc=schaefer@nbn.com \
--cc=zsh-users@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).