zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ifh.de>
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: Re: Various problems with 3.0.1-test1
Date: Tue, 10 Sep 1996 18:03:53 +0200	[thread overview]
Message-ID: <199609101603.SAA04007@hydra.ifh.de> (raw)
In-Reply-To: "Zoltan Hidvegi"'s message of "Tue, 10 Sep 1996 15:57:34 MET." <199609101357.PAA05991@bolyai.cs.elte.hu>

Zoltan Hidvegi wrote:
> > 2) This is very puzzling.
> > 
> > % ./zsh -fc 'setopt extendedglob;  [[ PATH = [A-Z]# ]] || print Failed.'
> > Failed.
> 
> This is know and probably not a bug.

I'm rather less sure.  The actual case that bothered me was more like
this.

% cat fntst
setopt extendedglob
[[ PATH = [A-Z]# ]] || print Failed
% ./zsh -fc 'fpath=.; autoload fntst; fntst'
Failed

This certainly looks to me like a bug.  I understand the point --- the
whole function is being parsed before extendedglob is set.  However,
there doesn't seem to be any way of making the function independent of
external options.  This is very unpleasant.  Explaining to people it's
not a bug because it's not supposed to work properly doesn't seem to
me the preferable answer.  It basically makes it impossible to use
extendedglob in portable functions.

In fact, the whole idea of the lexical tokens depending on some option
has me less than thrilled.  Since the only difference is in lextok2, I
think the following patch should work.  It has the bonus of making the
effect of extendedglob much more transparent in the code.  I would
urge its inclusion.  If you're counting, I've added seven extendedglob
tests and removed one.  I believe these are all the ones required.
(Maybe it was this way before?)

*** Src/glob.c.ext	Tue Sep 10 17:19:01 1996
--- Src/glob.c	Tue Sep 10 17:49:07 1996
***************
*** 788,800 ****
  		*str = '|';
  		break;
  	    } /* else fall through */
- 	case Pound:
- 	case Hat:
  	case Star:
  	case Inbrack:
  	case Inang:
  	case Quest:
  	    return str;
  	}
      if (!mod || parlev)
  	return NULL;
--- 788,802 ----
  		*str = '|';
  		break;
  	    } /* else fall through */
  	case Star:
  	case Inbrack:
  	case Inang:
  	case Quest:
  	    return str;
+ 	case Pound:
+ 	case Hat:
+ 	    if (isset(EXTENDEDGLOB))
+ 		return str;
  	}
      if (!mod || parlev)
  	return NULL;
***************
*** 1708,1715 ****
  	    pat++;
  	    continue;
  	}
! 	if (*pat == Hat)	/* following pattern is negated */
! 	    return 1 - doesmatch(c->next);
  	if (*pat == Inbrack) {
  	    /* Match groups of characters */
  #define PAT(X) (pat[X] == Meta ? pat[(X)+1] ^ 32 : untok(pat[X]))
--- 1710,1717 ----
  	    pat++;
  	    continue;
  	}
! 	if (*pat == Hat && isset(EXTENDEDGLOB))	
! 	    return 1 - doesmatch(c->next);  /* following pattern is negated */
  	if (*pat == Inbrack) {
  	    /* Match groups of characters */
  #define PAT(X) (pat[X] == Meta ? pat[(X)+1] ^ 32 : untok(pat[X]))
***************
*** 1897,1903 ****
  
      /* Parse repeated directories such as (dir/)# and (dir/)## */
      if (*(str = pptr) == Inpar && !skipparens(Inpar, Outpar, &str) &&
!         *str == Pound && str[-2] == '/') {
  	pptr++;
  	if (!(c1 = parsecompsw(0)))
  	    return NULL;
--- 1899,1905 ----
  
      /* Parse repeated directories such as (dir/)# and (dir/)## */
      if (*(str = pptr) == Inpar && !skipparens(Inpar, Outpar, &str) &&
!         *str == Pound && isset(EXTENDEDGLOB) && str[-2] == '/') {
  	pptr++;
  	if (!(c1 = parsecompsw(0)))
  	    return NULL;
***************
*** 1954,1960 ****
  	/* Go through code until we find something separating alternatives,
  	 * or path components if relevant.
  	 */
! 	if (*pptr == Hat) {
  	    /* negate remaining pattern */
  	    *s++ = Hat;
  	    *s++ = '\0';
--- 1956,1962 ----
  	/* Go through code until we find something separating alternatives,
  	 * or path components if relevant.
  	 */
! 	if (*pptr == Hat && isset(EXTENDEDGLOB)) {
  	    /* negate remaining pattern */
  	    *s++ = Hat;
  	    *s++ = '\0';
***************
*** 1995,2001 ****
  		errflag = 1;
  		return NULL;
  	    }
! 	    if (*pptr == Pound) {
  		/* Zero (or one) or more repetitions of group */
  		dpnd = 1;
  		pptr++;
--- 1997,2003 ----
  		errflag = 1;
  		return NULL;
  	    }
! 	    if (*pptr == Pound && isset(EXTENDEDGLOB)) {
  		/* Zero (or one) or more repetitions of group */
  		dpnd = 1;
  		pptr++;
***************
*** 2025,2031 ****
  	    c->str = dupstring(cstr);
  	    return c;
  	}
! 	if (*pptr == Pound) {
  	    /* repeat whatever we've just had (ls) zero or more times */
  	    *s = '\0';
  	    pptr++;
--- 2027,2033 ----
  	    c->str = dupstring(cstr);
  	    return c;
  	}
! 	if (*pptr == Pound && isset(EXTENDEDGLOB)) {
  	    /* repeat whatever we've just had (ls) zero or more times */
  	    *s = '\0';
  	    pptr++;
*** Src/lex.c.ext	Tue Sep 10 17:13:20 1996
--- Src/lex.c	Tue Sep 10 17:17:03 1996
***************
*** 315,320 ****
--- 315,322 ----
      lextok2['['] = Inbrack;
      lextok2['$'] = String;
      lextok2['~'] = Tilde;
+     lextok2['#'] = Pound;
+     lextok2['^'] = Hat;
  }
  
  /* initialize lexical state */
***************
*** 327,339 ****
      dbparens = alstat = lexstop = 0;
      incmdpos = 1;
      tok = ENDINPUT;
-     if (isset(EXTENDEDGLOB)) {
- 	lextok2['#'] = Pound;
- 	lextok2['^'] = Hat;
-     } else {
- 	lextok2['#'] = '#';
- 	lextok2['^'] = '^';
-     }
  }
  
  /* add a char to the string buffer */
--- 329,334 ----
*** Src/zle_tricky.c.ext	Tue Sep 10 17:18:53 1996
--- Src/zle_tricky.c	Tue Sep 10 17:25:21 1996
***************
*** 474,481 ****
  	    }
  	} else {
  	    /* Not a parameter expression so we check for wildcards */
! 	    if (*str == Pound || *str == Hat || *str == Star ||
! 		*str == Bar || *str == Quest ||
  		!skipparens(Inbrack, Outbrack, &str) ||
  		!skipparens(Inang,   Outang,   &str) ||
  		(unset(IGNOREBRACES) &&
--- 474,481 ----
  	    }
  	} else {
  	    /* Not a parameter expression so we check for wildcards */
! 	    if (((*str == Pound || *str == Hat) && isset(EXTENDEDGLOB)) ||
! 		*str == Star || *str == Bar || *str == Quest ||
  		!skipparens(Inbrack, Outbrack, &str) ||
  		!skipparens(Inang,   Outang,   &str) ||
  		(unset(IGNOREBRACES) &&


-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.


  reply	other threads:[~1996-09-11  4:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-10 12:10 Peter Stephenson
1996-09-10 13:57 ` Zoltan Hidvegi
1996-09-10 16:03   ` Peter Stephenson [this message]
1996-09-10 23:53     ` 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=199609101603.SAA04007@hydra.ifh.de \
    --to=pws@ifh.de \
    --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).