zsh-users
 help / color / mirror / code / Atom feed
From: Zoltan Hidvegi <hzoli@cs.elte.hu>
To: schaefer@nbn.com
Cc: segal@morgan.com, zsh-users@math.gatech.edu
Subject: Re: Bug in case stmt with '('
Date: Fri, 19 Jul 1996 01:43:26 +0200 (MET DST)	[thread overview]
Message-ID: <199607182343.BAA02057@hzoli.ppp.cs.elte.hu> (raw)
In-Reply-To: <9607181127.ZM13011@candle.brasslantern.com> 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;



  reply	other threads:[~1996-07-19  1:18 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 [this message]
1996-07-19  2:23     ` Bart Schaefer
1996-07-19 16:00       ` Zoltan Hidvegi
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=199607182343.BAA02057@hzoli.ppp.cs.elte.hu \
    --to=hzoli@cs.elte.hu \
    --cc=schaefer@nbn.com \
    --cc=segal@morgan.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).