about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Src/params.c2
-rw-r--r--Src/utils.c4
-rw-r--r--Test/B02typeset.ztst15
4 files changed, 23 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index d621b771b..3dd273437 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-09-17  Peter Stephenson  <pws@csr.com>
+
+	* 20378: Matthias B <msb@winterdrache.de>: Src/params.c,
+	Src/utils.c, B02typeset.ztst: Fix bugs with metafied characters
+	in tied arrays.
+
 2004-09-16  Peter Stephenson  <pws@csr.com>
 
 	* 20364: Functions/Completer/_oldlist: use $WIDGETSTYLE.
diff --git a/Src/params.c b/Src/params.c
index f9e382004..7ba0359b7 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2643,7 +2643,7 @@ tiedarrsetfn(Param pm, char *x)
 	if (imeta(dptr->joinchar))
 	{
 	    sepbuf[0] = Meta;
-	    sepbuf[1] = dptr->joinchar;
+	    sepbuf[1] = dptr->joinchar ^ 32;
 	    sepbuf[2] = '\0';
 	}
 	else
diff --git a/Src/utils.c b/Src/utils.c
index 143855160..ba31a1315 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -1912,16 +1912,14 @@ zjoin(char **arr, int delim, int heap)
     ptr = ret = (heap ? (char *) hcalloc(len) : (char *) zshcalloc(len));
     for (s = arr; *s; s++) {
 	strucpy(&ptr, *s);
-	if (delim) {
 	    if (imeta(delim)) {
 		*ptr++ = Meta;
 		*ptr++ = delim ^ 32;
 	    }
 	    else
 		*ptr++ = delim;
-	}
     }
-    ptr[-1] = '\0';
+    ptr[-1 - (imeta(delim) ? 1 : 0)] = '\0';
     return ret;
 }
 
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst
index 3a35b0467..752a8e94a 100644
--- a/Test/B02typeset.ztst
+++ b/Test/B02typeset.ztst
@@ -183,6 +183,21 @@
 >l o c a l
 >l:o:c:a l o c a
 
+ typeset -T SCALAR=$'l\x83o\x83c\x83a\x83l' array $'\x83'
+ print $array
+ typeset -U SCALAR
+ print $SCALAR $array
+0:Tied parameters and uniquified arrays with meta-character as separator
+>l o c a l
+>lƒoƒcƒa l o c a
+
+ typeset -T SCALAR=$'l\000o\000c\000a\000l' array $'\000'
+ typeset -U SCALAR
+ print $array
+ [[ $SCALAR == $'l\000o\000c\000a' ]]
+0:Tied parameters and uniquified arrays with NUL-character as separator
+>l o c a
+
  typeset -T SCALAR array
  typeset +T SCALAR
 1:Untying is prohibited