zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@math.gatech.edu (Zsh hackers list),
	Martin Birgmeier <Martin.Birgmeier@aon.at>
Subject: PATCH: Re: Bug in zsh-3.1.5 `case' pattern matching
Date: Tue, 10 Nov 1998 09:59:54 +0100	[thread overview]
Message-ID: <9811100859.AA23730@ibmth.df.unipi.it> (raw)
In-Reply-To: "Martin Birgmeier"'s message of "Sat, 07 Nov 1998 10:20:52 NFT." <364410F4.7B138182@aon.at>

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 <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarotti 2, 56100 Pisa, Italy


      parent reply	other threads:[~1998-11-10  9:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-11-07  9:20 Bug in zsh-3.1.5 Martin Birgmeier
1998-11-07 17:55 ` Bart Schaefer
1998-11-10  8:59 ` Peter Stephenson [this message]

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=9811100859.AA23730@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --cc=Martin.Birgmeier@aon.at \
    --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).