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

[PATCH] Make $functions re-settable.



---
Unlike the standard hash setter, setfunctions() wasn't checking that ht !=
pm->u.hash.  Rather than reimplement that, I chose (perhaps overzealously) to
delegate to the standard setter.

Cheers,

Daniel

 Src/Modules/parameter.c | 4 ++--
 Test/V06parameter.ztst  | 6 ++++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c
index 6e62287..c251e4f 100644
--- a/Src/Modules/parameter.c
+++ b/Src/Modules/parameter.c
@@ -330,7 +330,7 @@ unsetpmfunction(Param pm, UNUSED(int exp))
 
 /**/
 static void
-setfunctions(UNUSED(Param pm), HashTable ht, int dis)
+setfunctions(Param pm, HashTable ht, int dis)
 {
     int i;
     HashNode hn;
@@ -349,7 +349,7 @@ setfunctions(UNUSED(Param pm), HashTable ht, int dis)
 
 	    setfunction(hn->nam, ztrdup(getstrvalue(&v)), dis);
 	}
-    deleteparamtable(ht);
+    hashsetfn(pm, ht);
 }
 
 /**/
diff --git a/Test/V06parameter.ztst b/Test/V06parameter.ztst
index 10e0a27..27d5878 100644
--- a/Test/V06parameter.ztst
+++ b/Test/V06parameter.ztst
@@ -86,6 +86,12 @@
 >I have been autoloaded
 >$mydir/myfunc
 
+ functions+=(a 'echo foo'); a
+ functions+=(a 'echo bar'); a
+0:$functions can be appended to twice
+>foo
+>bar
+
 %clean
 
  rm -f autofn functrace.zsh rocky3.zsh sourcedfile myfunc



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