* PATCH: unset and assoc (was Re: Let's finish this new completion stuff)
@ 1999-02-23 12:54 Sven Wischnowsky
1999-02-23 18:38 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Sven Wischnowsky @ 1999-02-23 12:54 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
> zagzig% typeset -A foo
> zagzig% echo ${+foo[x]}
> 1
> zagzig% typeset -a bar
> zagzig% echo ${+bar[x]}
> 0
>
> That is, all fields of associative arrays currently appear to be set,
> even when they aren't; this is not true of plain arrays.
The problem was that at the time the lookup in the hastable occurs,
there is an struct pm for it with the PM_UNSET flag set. The patch
below makes this flag be tested in subst.c. I think this is the
simplest solution and the tests I did worked, does anyone see any
problems with this?
Bye
Sven
--- os/subst.c Mon Feb 22 10:49:23 1999
+++ Src/subst.c Tue Feb 23 13:47:42 1999
@@ -999,11 +999,12 @@
if (!(v = fetchvalue((subexp ? &ov : &s), (wantt ? -1 :
((unset(KSHARRAYS) || inbrace) ? 1 : -1)),
- hkeys|hvals)))
+ hkeys|hvals)) ||
+ (v->pm && (v->pm->flags & PM_UNSET)))
vunset = 1;
if (wantt) {
- if (v) {
+ if (v && v->pm && !(v->pm->flags & PM_UNSET)) {
int f = v->pm->flags;
switch (PM_TYPE(f)) {
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 2+ messages in thread
* PATCH: unset and assoc (was Re: Let's finish this new completion stuff)
1999-02-23 12:54 PATCH: unset and assoc (was Re: Let's finish this new completion stuff) Sven Wischnowsky
@ 1999-02-23 18:38 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 1999-02-23 18:38 UTC (permalink / raw)
To: Sven Wischnowsky; +Cc: zsh-workers
Sven Wischnowsky writes:
>
> The problem was that at the time the lookup in the hastable occurs,
> there is an struct pm for it with the PM_UNSET flag set. The patch
> below makes this flag be tested in subst.c.
This is the change that I expected was needed.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1999-02-23 18:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-23 12:54 PATCH: unset and assoc (was Re: Let's finish this new completion stuff) Sven Wischnowsky
1999-02-23 18:38 ` 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).