From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23735 invoked from network); 28 Dec 1996 20:03:04 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 28 Dec 1996 20:03:04 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id PAA07413; Sat, 28 Dec 1996 15:01:30 -0500 (EST) Resent-Date: Sat, 28 Dec 1996 15:01:30 -0500 (EST) From: Zoltan Hidvegi Message-Id: <199612281910.UAA15684@hzoli.ppp.cs.elte.hu> Subject: case bugfix To: zsh-workers@math.gatech.edu (Zsh hacking and development) Date: Sat, 28 Dec 1996 20:10:19 +0100 (MET) 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: <"4NeCJ.0.mp1.PoNno"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2656 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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) {