about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2015-08-31 14:52:59 +0200
committerMikael Magnusson <mikachu@gmail.com>2015-09-01 23:20:05 +0200
commit8e3ca08f13f198caa7cd7dc2bb37863238bea4f2 (patch)
tree9d61db4475d8a74c18d25a849ffa7de03b85892a
parentcbe00216fe2b61a4d00cd6bd8189063efc5e132a (diff)
downloadzsh-8e3ca08f13f198caa7cd7dc2bb37863238bea4f2.tar.gz
zsh-8e3ca08f13f198caa7cd7dc2bb37863238bea4f2.tar.xz
zsh-8e3ca08f13f198caa7cd7dc2bb37863238bea4f2.zip
36347: Fix appending empty array to associations
-rw-r--r--ChangeLog7
-rw-r--r--Src/params.c9
-rw-r--r--Test/A06assign.ztst8
3 files changed, 21 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 733ea688f..167d2f408 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-09-01  Mikael Magnusson  <mikachu@gmail.com>
+
+	* 36380: Src/utils.c: Avoid gcc case syntax
+
+	* 36347: Src/params.c, Test/A06assign.ztst: Fix appending empty
+	array to associations
+
 2015-09-01  Barton E. Schaefer  <schaefer@zsh.org>
 
 	* 36376: Src/utils.c: handle signals during read1char() so it is
diff --git a/Src/params.c b/Src/params.c
index 00f43e47d..de151a4cd 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -3312,9 +3312,12 @@ arrhashsetfn(Param pm, char **val, int augment)
 	zerr("bad set of key/value pairs for associative array");
 	return;
     }
-    if (alen)
-    	if (!(augment && (ht = paramtab = pm->gsu.h->getfn(pm))))
-	    ht = paramtab = newparamtable(17, pm->node.nam);
+    if (augment) {
+	ht = paramtab = pm->gsu.h->getfn(pm);
+    }
+    if (alen && (!augment || !paramtab)) {
+	ht = paramtab = newparamtable(17, pm->node.nam);
+    }
     while (*aptr) {
 	/* The parameter name is ztrdup'd... */
 	v->pm = createparam(*aptr, PM_SCALAR|PM_UNSET);
diff --git a/Test/A06assign.ztst b/Test/A06assign.ztst
index 302659c7e..1e3d2ede9 100644
--- a/Test/A06assign.ztst
+++ b/Test/A06assign.ztst
@@ -249,6 +249,14 @@
 >2
 >3
 
+ typeset -A h
+ h=(a 1 b 2)
+ h+=()
+ print -l $h
+0:add empty array to association
+>1
+>2
+
 # tests of var[range]+=scalar
 
  s=sting