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

Re: Clarify zshaddhistory doc?



On Wed, 18 Feb 2009 10:39:39 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Feb 18,  5:09pm, Peter Stephenson wrote:
> }
> } > What exactly does this mean?  There's no $zshaddhistory_functions array
> } > so "any of the hook functions" is either a typo, or must refer to the
> } > $preexec_functions hooks, which ought to be clearer.
> } 
> } There isn't a zshaddhistory_functions array until you add one, then
> } there is.
> 
> Hrm.  Well, then, perhaps the explicit reference to "preexec_functions"
> in Src/init.c is wrong, and it should be using the HOOK_SUFFIX constant?

Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.98
diff -u -r1.98 init.c
--- Src/init.c	11 Feb 2009 20:42:16 -0000	1.98
+++ Src/init.c	19 Feb 2009 09:57:52 -0000
@@ -150,7 +150,7 @@
 
 	    if (toplevel &&
 		(getshfunc("preexec") ||
-		 paramtab->getnode(paramtab, "preexec_functions"))) {
+		 paramtab->getnode(paramtab, "preexec" HOOK_SUFFIX))) {
 		LinkList args;
 		char *cmdstr;
 
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.208
diff -u -r1.208 utils.c
--- Src/utils.c	5 Jan 2009 21:56:53 -0000	1.208
+++ Src/utils.c	19 Feb 2009 09:57:52 -0000
@@ -1174,8 +1174,6 @@
     if (arrayp) {
 	char **arrptr;
 	int namlen = strlen(name);
-#define HOOK_SUFFIX	"_functions"
-#define HOOK_SUFFIX_LEN	11	/* including NUL byte */
 	VARARR(char, arrnam, namlen + HOOK_SUFFIX_LEN);
 	memcpy(arrnam, name, namlen);
 	memcpy(arrnam + namlen, HOOK_SUFFIX, HOOK_SUFFIX_LEN);
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.152
diff -u -r1.152 zsh.h
--- Src/zsh.h	11 Feb 2009 20:42:16 -0000	1.152
+++ Src/zsh.h	19 Feb 2009 09:57:52 -0000
@@ -1117,6 +1117,15 @@
 #define WRAPDEF(func) \
     { NULL, 0, func, NULL }
 
+/*
+ * User-defined hook arrays
+ */
+
+/* Name appended to function name to get hook array */
+#define HOOK_SUFFIX	"_functions"
+/* Length of that including NUL byte */
+#define HOOK_SUFFIX_LEN	11
+
 /* node in builtin command hash table (builtintab) */
 
 /*



-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



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