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

PATCH: Re: Assignments to nameddirs[]



Bart Schaefer wrote:

> On Oct 26, 10:36am, Sven Wischnowsky wrote:
> }
> } Bart Schaefer wrote:
> } 
> } > The parameter module "knows" that named directories must begin
> } > with a slash character, and normally doesn't let you assign such values.
> } > This can lead to some oddities like not being able to assign the value of
> } > a parameter to itself:
> } 
> } Hm. Should we change that?
> 
> Possibly so.
> 
> } I don't know why I added that test anymore. Maybe I somehow had the
> } impression that hash does the same? Hm.
> 
> It's probably because such a test is used to decide whether a reference
> to a parameter with ~paramname will cause an entry to be made in the
> nameddir table.  But assignment to the nameddirs special hash is more
> like using the "hash" command than it is like using ~paramname.

Yes, the patch copies the code from there.

Bye
 Sven

Index: Src/Modules/parameter.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/parameter.c,v
retrieving revision 1.17
diff -u -r1.17 parameter.c
--- Src/Modules/parameter.c	2000/08/16 09:25:40	1.17
+++ Src/Modules/parameter.c	2000/10/30 08:17:33
@@ -1399,11 +1399,15 @@
 static void
 setpmnameddir(Param pm, char *value)
 {
-    if (!value || *value != '/')
-	zwarn("invalid value: %s", value, 0);
-    else
-	adduserdir(pm->nam, value, 0, 1);
-    zsfree(value);
+    if (!value)
+	zwarn("invalid value: ''", NULL, 0);
+    else {
+	Nameddir nd = (Nameddir) zcalloc(sizeof(*nd));
+
+	nd->flags = 0;
+	nd->dir = value;
+	nameddirtab->addnode(nameddirtab, ztrdup(pm->nam), nd);
+    }
 }
 
 /**/
@@ -1444,10 +1448,15 @@
 	    v.arr = NULL;
 	    v.pm = (Param) hn;
 
-	    if (!(val = getstrvalue(&v)) || *val != '/')
-		zwarn("invalid value: %s", val, 0);
-	    else
-		adduserdir(hn->nam, val, 0, 1);
+	    if (!(val = getstrvalue(&v)))
+		zwarn("invalid value: ''", NULL, 0);
+	    else {
+		Nameddir nd = (Nameddir) zcalloc(sizeof(*nd));
+
+		nd->flags = 0;
+		nd->dir = ztrdup(val);
+		nameddirtab->addnode(nameddirtab, ztrdup(hn->nam), nd);
+	    }
 	}
 
     /* The INTERACTIVE stuff ensures that the dirs are not immediatly removed

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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