From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dns.primenet.com.au (dns.primenet.com.au [203.24.36.40]) by coral.primenet.com.au (8.7.5/8.7.3) with ESMTP id OAA00358 for ; Wed, 11 Sep 1996 14:19:42 +1000 (EST) Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by dns.primenet.com.au (8.7.5/8.7.3) with ESMTP id CAA00625 for ; Wed, 11 Sep 1996 02:39:47 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id MAA07374; Tue, 10 Sep 1996 12:05:37 -0400 (EDT) Resent-Date: Tue, 10 Sep 1996 12:05:37 -0400 (EDT) Message-Id: <199609101603.SAA04007@hydra.ifh.de> X-Authentication-Warning: hydra.ifh.de: Host pws@localhost didn't use HELO protocol To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: Re: Various problems with 3.0.1-test1 In-reply-to: "Zoltan Hidvegi"'s message of "Tue, 10 Sep 1996 15:57:34 MET." <199609101357.PAA05991@bolyai.cs.elte.hu> Date: Tue, 10 Sep 1996 18:03:53 +0200 From: Peter Stephenson Resent-Message-ID: <"i7pWZ2.0.8p1.G7PDo"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2123 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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 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.