From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29240 invoked from network); 23 Feb 1999 12:55:27 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 23 Feb 1999 12:55:27 -0000 Received: (qmail 5278 invoked by alias); 23 Feb 1999 12:54:58 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5490 Received: (qmail 5270 invoked from network); 23 Feb 1999 12:54:53 -0000 Date: Tue, 23 Feb 1999 13:54:07 +0100 (MET) Message-Id: <199902231254.NAA24702@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Bart Schaefer"'s message of Sun, 21 Feb 1999 16:15:42 -0800 Subject: PATCH: unset and assoc (was Re: Let's finish this new completion stuff) 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