Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: `typeset -U' and exported tied parameters



"Bart Schaefer" wrote:
> Note that although `typeset -U' has changed both the array and the tied
> parameter, it has failed to update the exported copy of the tied parameter.

This is the easy fix.  This is similar to the same problem with
lower/uppercasing of parameter.  I didn't look further because we sort of
agreed that parameter getting and setting could do with a complete
rewrite.  (The number of things we've agreed over the years could do with a
complete rewrite is large.  It's an immensely satisfying and timesaving
thing to do.  Unfortunately it doesn't get anything fixed.)

The change to uniqarray() is just because no-one was using the return
value.

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.14
diff -u -r1.14 builtin.c
--- Src/builtin.c	2000/05/05 07:42:36	1.14
+++ Src/builtin.c	2000/05/10 19:04:25
@@ -1607,11 +1607,20 @@
 	}
 	if ((on & PM_UNIQUE) && !(pm->flags & PM_READONLY & ~off)) {
 	    Param apm;
-	    if (PM_TYPE(pm->flags) == PM_ARRAY)
-		uniqarray((*pm->gets.afn) (pm));
-	    else if (PM_TYPE(pm->flags) == PM_SCALAR && pm->ename &&
-		     (apm = (Param) paramtab->getnode(paramtab, pm->ename)))
-		uniqarray((*apm->gets.afn) (apm));
+	    char **x;
+	    if (PM_TYPE(pm->flags) == PM_ARRAY) {
+		x = (*pm->gets.afn)(pm);
+		uniqarray(x);
+		if (pm->ename && x)
+		    arrfixenv(pm->ename, x);
+	    } else if (PM_TYPE(pm->flags) == PM_SCALAR && pm->ename &&
+		       (apm =
+			(Param) paramtab->getnode(paramtab, pm->ename))) {
+		x = (*apm->gets.afn)(apm);
+		uniqarray(x);
+		if (x)
+		    arrfixenv(pm->nam, x);
+	    }
 	}
 	pm->flags = (pm->flags | on) & ~(off | PM_UNSET);
 	/* This auxlen/pm->ct stuff is a nasty hack. */
Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.7
diff -u -r1.7 params.c
--- Src/params.c	2000/04/27 08:21:10	1.7
+++ Src/params.c	2000/05/10 19:04:35
@@ -2299,10 +2299,9 @@
 }
 
 /**/
-int
+void
 uniqarray(char **x)
 {
-    int changes = 0;
     char **t, **p = x;
 
     if (!x || !*x)
@@ -2312,10 +2311,8 @@
 	    if (!strcmp(*p, *t)) {
 		zsfree(*p);
 		for (t = p--; (*t = t[1]) != NULL; t++);
-		changes++;
 		break;
 	    }
-    return changes;
 }
 
 /* Function to get value of special parameter `#' and `ARGC' */
@@ -2759,7 +2756,7 @@
  * do the replacing, since we've already scanned for the string. */
 
 /**/
-static void
+void
 arrfixenv(char *s, char **t)
 {
     char **ep, *u;

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
Work: pws@xxxxxxxxxxxxxxxxxxxxxxxxx
Web: http://www.pwstephenson.fsnet.co.uk



Messages sorted by: Reverse Date, Date, Thread, Author