* zpc_special [was Re: question about glob qualifier format (#qx)]
[not found] ` <130921013028.ZM17637@torch.brasslantern.com>
@ 2013-09-21 23:35 ` Bart Schaefer
2013-09-21 23:52 ` Bart Schaefer
2013-09-23 19:47 ` Peter Stephenson
0 siblings, 2 replies; 4+ messages in thread
From: Bart Schaefer @ 2013-09-21 23:35 UTC (permalink / raw)
To: zsh-workers
On Sep 21, 1:30am, Bart Schaefer wrote:
}
} I accidentally encountered some odd behavior while confirming this.
} With NO_EXTENDED_GLOB, #q is not supposed to be available to introduce
} qualifiers. However
}
} % setopt NO_EXTENDED_GLOB
} % echo *(#q@)
} <list of symlinks>
}
} Whereas
}
} % echo *(#q/)
} zsh: unknown file attribute
}
} This is inconsistent, that is, sometimes (#q@) will also give "unknown"
} and (#q/) will work.
I believe this has to do with the new zpc_special[] array in pattern.c.
The first time we enter zglob(), it has not been initalized yet (?) and
so "#" is believed to be an active pattern chracter even though the
EXTENDED_GLOB option may not be set. The next time through zpc_special
will have been initialized, but it doesn't get re-initialized when the
extendedglob option is toggled (?) so the parsing of "#" may be left in
the wrong state.
Or something along those lines; PWS will have a better idea what is
going on, I hope.
I suspect glob.c:zglob() needs to call pattern.c:patparsecharset() before
it begins parsing the qualifiers, but the latter is static in parse.c, so
it isn't called until zglob() calls parsepat() much later, and I don't
follow the ramifications of calling patparsecharset() more than once for
the same pattern because the whole array gets clobbered and reset on each
call. Maybe harmless, I again hope PWS will have a better idea.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: zpc_special [was Re: question about glob qualifier format (#qx)]
2013-09-21 23:35 ` zpc_special [was Re: question about glob qualifier format (#qx)] Bart Schaefer
@ 2013-09-21 23:52 ` Bart Schaefer
2013-09-23 19:47 ` Peter Stephenson
1 sibling, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2013-09-21 23:52 UTC (permalink / raw)
To: zsh-workers
On Sep 21, 4:35pm, Bart Schaefer wrote:
}
} I believe this has to do with the new zpc_special[] array in pattern.c.
} The first time we enter zglob(), it has not been initalized yet (?) and
} so "#" is believed to be an active pattern chracter even though the
} EXTENDED_GLOB option may not be set. The next time through zpc_special
} will have been initialized, but it doesn't get re-initialized when the
} extendedglob option is toggled (?) so the parsing of "#" may be left in
} the wrong state.
Confirmation of this -- if I make sure to evaluate an unqualified pattern
before evaluating each qualified glob, then everything "works":
schaefer[528] Src/zsh -f
torch% print *(#q/)
Config Doc Etc Src Test
torch% print *(#q/)
zsh: unknown file attribute: #
torch%
schaefer[529] Src/zsh -f
torch% : *
torch% print *(#q/)
zsh: unknown file attribute: #
torch% setopt extendedglob
torch% print *(#q/)
zsh: unknown file attribute: #
torch% : *
torch% print *(#q/)
Config Doc Etc Src Test
torch%
(I tweaked the "unknown file attribute" error message to get it to show
what character caused the failure, which I figure is helpful so I've
committed/pushed it as an unposted change.)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: zpc_special [was Re: question about glob qualifier format (#qx)]
2013-09-21 23:35 ` zpc_special [was Re: question about glob qualifier format (#qx)] Bart Schaefer
2013-09-21 23:52 ` Bart Schaefer
@ 2013-09-23 19:47 ` Peter Stephenson
2013-09-24 6:27 ` Bart Schaefer
1 sibling, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2013-09-23 19:47 UTC (permalink / raw)
To: zsh-workers
On Sat, 21 Sep 2013 16:35:31 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Sep 21, 1:30am, Bart Schaefer wrote:
> }
> } I accidentally encountered some odd behavior while confirming this.
> } With NO_EXTENDED_GLOB, #q is not supposed to be available to introduce
> } qualifiers. However
> }
> } % setopt NO_EXTENDED_GLOB
> } % echo *(#q@)
> } <list of symlinks>
> }
> } Whereas
> }
> } % echo *(#q/)
> } zsh: unknown file attribute
> }
> } This is inconsistent, that is, sometimes (#q@) will also give "unknown"
> } and (#q/) will work.
>
> I believe this has to do with the new zpc_special[] array in pattern.c.
I'm aware of unfinished business for actually disabling hashes, but the
problem here is I'm using the array that's only initialised when you set
up a pattern too early in the glob process, which is why it sometimes
does the right thing after you've used a pattern.
See if this fixes everything you found...
diff --git a/Src/glob.c b/Src/glob.c
index 9299b95..0c7d22d 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -1112,7 +1112,8 @@ zglob(LinkList list, LinkNode np, int nountok)
gf_pre_words = NULL;
/* Check for qualifiers */
- while (!nobareglob || zpc_special[ZPC_HASH] != Marker) {
+ while (!nobareglob ||
+ (isset(EXTENDEDGLOB) && !zpc_disables[ZPC_HASH])) {
struct qual *newquals;
char *s;
int sense, paren;
@@ -1158,11 +1159,11 @@ zglob(LinkList list, LinkNode np, int nountok)
case Outpar:
paren++; /*FALLTHROUGH*/
case Bar:
- if (zpc_special[ZPC_BAR] != Marker)
+ if (!zpc_disables[ZPC_BAR])
nobareglob = 1;
break;
case Tilde:
- if (zpc_special[ZPC_TILDE] != Marker)
+ if (!isset(EXTENDEDGLOB) || !zpc_disables[ZPC_TILDE])
nobareglob = 1;
break;
case Inpar:
@@ -1172,7 +1173,7 @@ zglob(LinkList list, LinkNode np, int nountok)
}
if (*s != Inpar)
break;
- if (s[1] == zpc_special[ZPC_HASH]) {
+ if (isset(EXTENDEDGLOB) && !zpc_disables[ZPC_HASH] && s[1] == Pound) {
if (s[2] == 'q') {
*s = 0;
s += 2;
diff --git a/Src/pattern.c b/Src/pattern.c
index b7897e7..4f0166b 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -245,7 +245,8 @@ static const char *zpc_strings[ZPC_COUNT] = {
* Corresponding array of pattern disables as set by the user
* using "disable -p".
*/
-static char zpc_disables[ZPC_COUNT];
+/**/
+char zpc_disables[ZPC_COUNT];
/*
* Stack of saved (compressed) zpc_disables for function scope.
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: zpc_special [was Re: question about glob qualifier format (#qx)]
2013-09-23 19:47 ` Peter Stephenson
@ 2013-09-24 6:27 ` Bart Schaefer
0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2013-09-24 6:27 UTC (permalink / raw)
To: zsh-workers
On Sep 23, 8:47pm, Peter Stephenson wrote:
}
} On Sat, 21 Sep 2013 16:35:31 -0700
} Bart Schaefer <schaefer@brasslantern.com> wrote:
} >
} > I believe this has to do with the new zpc_special[] array in pattern.c.
}
} See if this fixes everything you found...
Looks good to me.
--
Barton E. Schaefer
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-09-24 6:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20130920111110.GA4501@localhost.localdomain>
[not found] ` <20130920123830.30111071@pwslap01u.europe.root.pri>
[not found] ` <20130920233930.GB4501@localhost.localdomain>
[not found] ` <130921013028.ZM17637@torch.brasslantern.com>
2013-09-21 23:35 ` zpc_special [was Re: question about glob qualifier format (#qx)] Bart Schaefer
2013-09-21 23:52 ` Bart Schaefer
2013-09-23 19:47 ` Peter Stephenson
2013-09-24 6:27 ` Bart Schaefer
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).