zsh-workers
 help / color / mirror / code / Atom feed
From: Zoltan Hidvegi <hzoli@cs.elte.hu>
To: zsh-workers@math.gatech.edu (Zsh hacking and development)
Subject: case bugfix
Date: Sat, 28 Dec 1996 20:10:19 +0100 (MET)	[thread overview]
Message-ID: <199612281910.UAA15684@hzoli.ppp.cs.elte.hu> (raw)

There is quite serious bug in case:

case * in
\*) echo yes;;
esac

This should print yes but you get `zsh: too many arguments to case' if
there are more than one files in the current directory.

Fix is included below.  This should be applied to zsh-3.0.2 as well.

Zoltan


*** Src/parse.c	1996/12/21 02:35:32	3.1.1.0
--- Src/parse.c	1996/12/28 18:38:33
***************
*** 481,487 ****
  {
      int brflag;
      LinkList pats, lists;
!     int n = 0;
      char **pp;
      List *ll;
      LinkNode no;
--- 481,487 ----
  {
      int brflag;
      LinkList pats, lists;
!     int n = 1;
      char **pp;
      List *ll;
      LinkNode no;
***************
*** 492,498 ****
      yylex();
      if (tok != STRING)
  	YYERRORV;
!     addlinknode(c->args, tokstr);
      incmdpos = 1;
      yylex();
      while (tok == SEPER)
--- 492,499 ----
      yylex();
      if (tok != STRING)
  	YYERRORV;
!     pats = newlinklist();
!     addlinknode(pats, tokstr);
      incmdpos = 1;
      yylex();
      while (tok == SEPER)
***************
*** 504,510 ****
      incmdpos = 0;
      yylex();
      cc = c->u.casecmd = (struct casecmd *)make_casecmd();
-     pats = newlinklist();
      lists = newlinklist();
      for (;;) {
  	char *str;
--- 505,510 ----
*** Src/exec.c	1996/12/27 01:31:33	3.1.1.2
--- Src/exec.c	1996/12/28 18:39:38
***************
*** 1208,1215 ****
      }
  
      /* Do prefork substitutions */
!     prefork(args, (((type == CCASE) ? 4 : 0)
! 		   | (assign ? 2 : isset(MAGICEQUALSUBST))));
  
      if (type == SIMPLE) {
  	int unglobbed = 0;
--- 1208,1214 ----
      }
  
      /* Do prefork substitutions */
!     prefork(args, assign ? 2 : isset(MAGICEQUALSUBST));
  
      if (type == SIMPLE) {
  	int unglobbed = 0;
*** Src/loop.c	1996/12/21 02:35:32	3.1.1.0
--- Src/loop.c	1996/12/28 18:41:19
***************
*** 374,397 ****
  {
      struct casecmd *node;
      char *word;
-     LinkList args;
      List *l;
      char **p;
  
      node = cmd->u.casecmd;
-     args = cmd->args;
      l = node->lists;
      p = node->pats;
  
      lastval = 0;
!     if (firstnode(args) && nextnode(firstnode(args))) {
! 	zerr("too many arguments to case", NULL, 0);
! 	return 1;
!     }
!     if (empty(args))
! 	word = dupstring("");
!     else
! 	word = (char *)peekfirst(args);
  
      if (node) {
  	while (*p) {
--- 374,390 ----
  {
      struct casecmd *node;
      char *word;
      List *l;
      char **p;
  
      node = cmd->u.casecmd;
      l = node->lists;
      p = node->pats;
  
      lastval = 0;
!     word = *p++;
!     singsub(&word);
!     untokenize(word);
  
      if (node) {
  	while (*p) {


             reply	other threads:[~1996-12-28 20:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-12-28 19:10 Zoltan Hidvegi [this message]
1996-12-28 21:11 ` Richard Coleman
1996-12-29  2:42   ` Zoltan Hidvegi

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=199612281910.UAA15684@hzoli.ppp.cs.elte.hu \
    --to=hzoli@cs.elte.hu \
    --cc=zsh-workers@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).