zsh-workers
 help / color / mirror / code / Atom feed
* Re: `typeset -U' and exported tied parameters
@ 2000-05-10 22:56 Oliver Kiddle
  0 siblings, 0 replies; 3+ messages in thread
From: Oliver Kiddle @ 2000-05-10 22:56 UTC (permalink / raw)
  To: zsh-workers

Peter Stephenson wrote:

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

You missed the other return statement so I got an error message from the
SGI compiler (gcc only gives a warning).

Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.8
diff -u -r1.8 params.c
--- Src/params.c        2000/05/10 19:15:58     1.8
+++ Src/params.c        2000/05/10 23:49:27
@@ -2305,7 +2305,7 @@
     char **t, **p = x;
 
     if (!x || !*x)
-       return 0;
+       return;
     while (*++p)
        for (t = x; t < p; t++)
            if (!strcmp(*p, *t)) {


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: `typeset -U' and exported tied parameters
  2000-05-10 15:59 Bart Schaefer
@ 2000-05-10 19:07 ` Peter Stephenson
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2000-05-10 19:07 UTC (permalink / raw)
  To: zsh-workers

"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@pwstephenson.fsnet.co.uk>
Work: pws@CambridgeSiliconRadio.com
Web: http://www.pwstephenson.fsnet.co.uk


^ permalink raw reply	[flat|nested] 3+ messages in thread

* `typeset -U' and exported tied parameters
@ 2000-05-10 15:59 Bart Schaefer
  2000-05-10 19:07 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2000-05-10 15:59 UTC (permalink / raw)
  To: zsh-workers

This has something to do with the FPATH problem (11281 et al.), but I still
don't know precisely what.

zagzig% echo $ZSH_VERSION
3.1.7-pre-3
zagzig% MANPATH=/usr/man:/usr/man:/usr/man 
zagzig% printenv MANPATH
/usr/man:/usr/man:/usr/man
zagzig% print $manpath
/usr/man /usr/man /usr/man
zagzig% typeset -U manpath
zagzig% printenv MANPATH
/usr/man:/usr/man:/usr/man
zagzig% print $MANPATH
/usr/man
zagzig% print $manpath
/usr/man

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.

zagzig% MANPATH=$MANPATH
zagzig% printenv MANPATH
/usr/man

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-05-10 23:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-10 22:56 `typeset -U' and exported tied parameters Oliver Kiddle
  -- strict thread matches above, loose matches on Subject: below --
2000-05-10 15:59 Bart Schaefer
2000-05-10 19:07 ` Peter Stephenson

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).