From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: Strange associative array stuff in pws-9
Date: Mon, 22 Feb 1999 13:55:03 +0100 (MET) [thread overview]
Message-ID: <199902221255.NAA21899@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Sat, 20 Feb 1999 17:17:34 -0800
Bart Schaefer wrote:
> Has it always been like this?
>
> zagzig% typeset -A foo
> zagzig% foo[a,b,c]=bar
> zagzig% echo $foo
> bar
> zagzig% echo $foo[a,b,c]
> bar[a,b,c]
> zagzig% echo ${foo[a,b,c]}
> bar
> zagzig% echo $foo['a,b,c']
> ['a,b,c']
> zagzig%
I was fearing that I had broken something, but this was in a piece of
the code I haven't touched...
The loop in getarg() searched for the first comma or closing bracket
even when subscripting an associative array. Since it doesn't make
sense to use ranges for associative arrays (and the docs say that they
are not supported), we should tell the code about it.
Bye
Sven
--- os/params.c Mon Feb 22 10:49:22 1999
+++ Src/params.c Mon Feb 22 13:49:42 1999
@@ -679,11 +679,13 @@
static long
getarg(char **str, int *inv, Value v, int a2, long *w)
{
- int num = 1, word = 0, rev = 0, ind = 0, down = 0, l, i;
+ int num = 1, word = 0, rev = 0, ind = 0, down = 0, l, i, ishash;
char *s = *str, *sep = NULL, *t, sav, *d, **ta, **p, *tt;
long r = 0;
Comp c;
+ ishash = (v->pm && PM_TYPE(v->pm->flags) == PM_HASHED);
+
/* first parse any subscription flags */
if (v->pm && (*s == '(' || *s == Inpar)) {
int escapes = 0;
@@ -771,12 +773,13 @@
} else if (rev) {
v->isarr |= SCANPM_WANTVALS;
}
- if (!down && v->pm && PM_TYPE(v->pm->flags) == PM_HASHED)
+ if (!down && ishash)
v->isarr &= ~SCANPM_MATCHMANY;
*inv = ind;
}
- for (t=s, i=0; *t && ((*t != ']' && *t != Outbrack && *t != ',') || i); t++)
+ for (t=s, i=0;
+ *t && ((*t != ']' && *t != Outbrack && (ishash || *t != ',')) || i); t++)
if (*t == '[' || *t == Inbrack)
i++;
else if (*t == ']' || *t == Outbrack)
@@ -791,7 +794,7 @@
singsub(&s);
if (!rev) {
- if (v->pm && PM_TYPE(v->pm->flags) == PM_HASHED) {
+ if (ishash) {
HashTable ht = v->pm->gets.hfn(v->pm);
if (!ht) {
ht = newparamtable(17, v->pm->nam);
@@ -867,7 +870,7 @@
if ((c = parsereg(s))) {
if (v->isarr) {
- if (PM_TYPE(v->pm->flags) == PM_HASHED) {
+ if (ishash) {
scancomp = c;
if (ind)
v->isarr |= SCANPM_MATCHKEY;
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~1999-02-22 12:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-02-22 12:55 Sven Wischnowsky [this message]
-- strict thread matches above, loose matches on Subject: below --
1999-02-21 1:17 Bart Schaefer
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=199902221255.NAA21899@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@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).