zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: Re: Assignments to nameddirs[]
Date: Mon, 30 Oct 2000 09:18:06 +0100 (MET)	[thread overview]
Message-ID: <200010300818.JAA18888@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Fri, 27 Oct 2000 15:35:52 +0000


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


                 reply	other threads:[~2000-10-30  8:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200010300818.JAA18888@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).