zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Gabor <gabor@vmunix.com>, zsh-users@sunsite.auc.dk
Subject: PATCH: ksharrays and assoc array assignments (was Re: Files modified after a given date)
Date: Sat, 28 Aug 1999 05:00:03 +0000	[thread overview]
Message-ID: <990828050003.ZM30545@candle.brasslantern.com> (raw)
In-Reply-To: <19990827194419.A7511@vmunix.com>

On Aug 27,  7:44pm, Gabor wrote:
} Subject: Re: Files modified after a given date
}
} On Fri, Aug 27, 1999 at 10:43:47PM +0000, Bart Schaefer wrote:
} # On Aug 27,  5:51pm, Gabor wrote:
} # > Subject: Re: Files modified after a given date
} # > === gabor $ builtin stat -H foo .zshrc
} # > zsh: attempt to set slice of associative array
} # 
} Well, I figured it out.  I believe this to be a bug, though you
} decide.  I always set ksharrays since I like 0 based indexing and use
} ksh for scripting at work.  With ksharrays unset, it works.

Aha.  Yes, that's a bug.  You can see it more easily with

zsh% setopt ksharrays
zsh% : ${(AA)=foo:=a b c d}
zsh: attempt to set slice of associative array

Here'a patch.

Index: Src/params.c
===================================================================
@@ -1697,9 +1697,14 @@
 	    v = NULL;
 	}
     }
-    if (!v)
-	if (!(v = getvalue(&t, 1)))
-	    return NULL;
+    if (!v) {
+	int k = opts[KSHARRAYS];	/* Remember the value of KSHARRAYS */
+	opts[KSHARRAYS] = 0;		/* and clear it to avoid special-  */
+	v = getvalue(&t, 1);		/* case of $array --> ${array[0]}. */
+	opts[KSHARRAYS] = k;		/* OK because we can't assign to a */
+	if (!v)				/* slice of an association anyway, */
+	    return NULL;		/* so ANY subscript will be wrong. */
+    }
     setarrvalue(v, val);
     return v->pm;
 }

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


  reply	other threads:[~1999-08-28  5:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-23  8:09 Files modified after a given date Sven Wischnowsky
1999-08-27 21:51 ` Gabor
1999-08-27 22:09   ` Bruce Stephens
1999-08-27 22:43   ` Bart Schaefer
1999-08-27 23:44     ` Gabor
1999-08-28  5:00       ` Bart Schaefer [this message]
1999-08-28 17:14         ` PATCH: ksharrays and assoc array assignments (was Re: Files modified after a given date) Gabor

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=990828050003.ZM30545@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=gabor@vmunix.com \
    --cc=zsh-users@sunsite.auc.dk \
    /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).