From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26776 invoked from network); 30 Oct 2000 08:18:21 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 30 Oct 2000 08:18:21 -0000 Received: (qmail 17136 invoked by alias); 30 Oct 2000 08:18:10 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13095 Received: (qmail 17129 invoked from network); 30 Oct 2000 08:18:09 -0000 Date: Mon, 30 Oct 2000 09:18:06 +0100 (MET) Message-Id: <200010300818.JAA18888@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Bart Schaefer"'s message of Fri, 27 Oct 2000 15:35:52 +0000 Subject: 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@informatik.hu-berlin.de