about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2001-04-22 21:04:10 +0000
committerBart Schaefer <barts@users.sourceforge.net>2001-04-22 21:04:10 +0000
commiteee9d4975590579b645207f54eaa78b8dcbb3d95 (patch)
treeead19c3644682663d25bf7cbf181b2c98fd03fdd
parent740d5765604573c9528747890ef30464a734888d (diff)
downloadzsh-eee9d4975590579b645207f54eaa78b8dcbb3d95.tar.gz
zsh-eee9d4975590579b645207f54eaa78b8dcbb3d95.tar.xz
zsh-eee9d4975590579b645207f54eaa78b8dcbb3d95.zip
Fix bug in (kK) subscript flags.
-rw-r--r--Src/params.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/Src/params.c b/Src/params.c
index f2fac0546..3f364d1a3 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -924,14 +924,17 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w)
 		       (ishash || c != ',')) || i); t++) {
 	/* Untokenize INULL() except before brackets, for parsestr() */
 	if (INULL(c)) {
-	    if (t[1] == '[' || t[1] == ']') {
+	    c = t[1];
+	    if (c == '[' || c == ']' ||
+		c == '(' || c == ')' ||
+		c == '{' || c == '}') {
 		/* This test handles nested subscripts in hash keys */
 		if (ishash && i)
-		    *t = ztokens[c - Pound];
+		    *t = ztokens[*t - Pound];
 		needtok = 1;
 		++t;
 	    } else
-		*t = ztokens[c - Pound];
+		*t = ztokens[*t - Pound];
 	    continue;
 	}
 	/* Inbrack and Outbrack are probably never found here ... */
@@ -950,7 +953,7 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w)
      * are not backslashed after parsestr().  Otherwise leave them alone *
      * so that the brackets will be escaped when we patcompile() or when *
      * subscript arithmetic is performed (for nested subscripts).        */
-    if (ishash && !rev)
+    if (ishash && (keymatch || !rev))
 	remnulargs(s);
     if (needtok) {
 	if (parsestr(s))
@@ -1034,8 +1037,10 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w)
 		}
 	    }
 	}
-	tokenize(s);
-	remnulargs(s);
+	if (!keymatch) {
+	    tokenize(s);
+	    remnulargs(s);
+	}
 
 	if (keymatch || (pprog = patcompile(s, 0, NULL))) {
 	    int len;
@@ -1044,10 +1049,9 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w)
 		if (ishash) {
 		    scanprog = pprog;
 		    scanstr = s;
-		    if (keymatch) {
-			untokenize(s);
+		    if (keymatch)
 			v->isarr |= SCANPM_KEYMATCH;
-		    } else if (ind)
+		    else if (ind)
 			v->isarr |= SCANPM_MATCHKEY;
 		    else
 			v->isarr |= SCANPM_MATCHVAL;