From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11773 invoked from network); 10 Nov 1998 09:20:23 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 10 Nov 1998 09:20:23 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id EAA22102; Tue, 10 Nov 1998 04:15:21 -0500 (EST) Resent-Date: Tue, 10 Nov 1998 04:15:21 -0500 (EST) Message-Id: <9811100859.AA23730@ibmth.df.unipi.it> To: zsh-workers@math.gatech.edu (Zsh hackers list), Martin Birgmeier Subject: PATCH: Re: Bug in zsh-3.1.5 `case' pattern matching In-Reply-To: "Martin Birgmeier"'s message of "Sat, 07 Nov 1998 10:20:52 NFT." <364410F4.7B138182@aon.at> Date: Tue, 10 Nov 1998 09:59:54 +0100 From: Peter Stephenson Resent-Message-ID: <"BBXND3.0.HP5.fG0Is"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4595 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu I replied to this on Sunday but it looks like it didn't get to the list, so I'm assuming it didn't get anywhere. Martin Birgmeier wrote: > $ echo echo "${HOSTTYPE:-$OSTYPE}:${TERM}:${TTY}" <--- informational > freebsd2.2.7:xterm:/dev/ttyp0 > > $ case "${HOSTTYPE:-$OSTYPE}:${TERM}:${TTY}" in <--- DOES NOT WORK > freebsd*:xterm:* | freebsd*:xterms:* ) > echo yes > ;; > * ) > echo no > ;; > esac > no The problem was that the pattern matcher didn't know that the `|' was the end of the pattern, because the alternative after it was completely separate. The reason is that `|'s are usually buried inside parentheses, so aren't the end of a pattern. That was so in the old `case' code, which just stuck an open parenthesis in front. This makes a difference because it needs to know whether the final part of the pattern, here `*', is forced to reach the end of the test string. So Bart's suggestion that there was a parse error is correct. Luckily the same problem already turned up with `~', the exclusion pattern, so fixing it with `|' is easy. *** Src/glob.c.bar Sun Nov 8 16:03:29 1998 --- Src/glob.c Sun Nov 8 16:01:28 1998 *************** *** 594,600 **** pptr[1] && pptr[1] != Outpar && pptr[1] != Bar) || *pptr == Outpar) { if (*pptr == '/' || !*pptr || ! (isset(EXTENDEDGLOB) && *pptr == Tilde && (gflag & GF_TOPLEV))) c->stat |= C_LAST; return c; --- 594,601 ---- pptr[1] && pptr[1] != Outpar && pptr[1] != Bar) || *pptr == Outpar) { if (*pptr == '/' || !*pptr || ! ((*pptr == Bar || ! (isset(EXTENDEDGLOB) && *pptr == Tilde)) && (gflag & GF_TOPLEV))) c->stat |= C_LAST; return c; *************** *** 746,752 **** } /* mark if last pattern component in path component or pattern */ if (*pptr == '/' || !*pptr || ! (isset(EXTENDEDGLOB) && *pptr == Tilde && (gflag & GF_TOPLEV))) c->stat |= C_LAST; c->str = dupstrpfx(cstr, pptr - cstr); return c; --- 747,754 ---- } /* mark if last pattern component in path component or pattern */ if (*pptr == '/' || !*pptr || ! ((*pptr == Bar || ! (isset(EXTENDEDGLOB) && *pptr == Tilde)) && (gflag & GF_TOPLEV))) c->stat |= C_LAST; c->str = dupstrpfx(cstr, pptr - cstr); return c; -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarotti 2, 56100 Pisa, Italy