zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Martin Birgmeier <Martin.Birgmeier@aon.at>, zsh-workers@math.gatech.edu
Subject: Re: Bug in zsh-3.1.5
Date: Sat, 7 Nov 1998 09:55:39 -0800	[thread overview]
Message-ID: <981107095539.ZM7795@candle.brasslantern.com> (raw)
In-Reply-To: <364410F4.7B138182@aon.at>

On Nov 7, 10:20am, Martin Birgmeier wrote:
} Subject: Bug in zsh-3.1.5
}
} $ 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
}
} It seems that the second choice of the first case label controls the truth
} value of the expression!

Actually, it's the first alternative in that label that is at fault, and
it only incidentally has to do with the new grouping syntax.

The pattern match fails in matchonce() after executing the code at about
line 2497.  The comment on line 2496 says:
	    /* optimisation when next pattern is not a closure */
The current pattern at this point is the "*" just to the left of the "|"
and the next pattern is the empty string.  The text being matched is
"/dev/ttyp0", the "freebsd2.2.7:xterm:" part already having correctly
matched.

Up at around line 2217, in doesmatch(), this condition failed:

	    if (STARP(c) && c->next &&
		!c->next->left && (looka = *c->next->str) &&
		!itok(looka)) {

because *(c->next->str) is 0 -- which means that even though STARP(c) is
true, it didn't consume "/dev/ttyp0" before calling matchonce().

Now, arguably the empty string ought to match anywhere, so one possible
fix is to change the condition above to:

	    if (STARP(c) && c->next && !c->next->left &&
		((looka = *c->next->str) && !itok(looka) || !looka)) {

However, I'm concerned that the real problem is that the pattern was not
parsed correctly, i.e. the trailing empty string should never have been
there in the first place; so I'm reluctant to recommend that change.  I
don't have time to re-learn the pattern-parsing code just now. :-/

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


  reply	other threads:[~1998-11-07 18:03 UTC|newest]

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

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=981107095539.ZM7795@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --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).