about summary refs log tree commit diff
path: root/Src/utils.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2002-05-21 11:10:13 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2002-05-21 11:10:13 +0000
commitafe1b00e16c7efc5c93c958fa4f357325977a2a1 (patch)
tree7a849e6fd30ece41051716bb900fc093f8792889 /Src/utils.c
parent5a89ede77be4ff696a77fb609ab29f5bf1e1dc37 (diff)
downloadzsh-afe1b00e16c7efc5c93c958fa4f357325977a2a1.tar.gz
zsh-afe1b00e16c7efc5c93c958fa4f357325977a2a1.tar.xz
zsh-afe1b00e16c7efc5c93c958fa4f357325977a2a1.zip
17141 plus mods: add `zle -F fd handler' feature.
Diffstat (limited to 'Src/utils.c')
-rw-r--r--Src/utils.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/Src/utils.c b/Src/utils.c
index 6a0c27e29..24d336b7a 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -624,6 +624,30 @@ time_t lastmailcheck;
 /**/
 time_t lastwatch;
 
+/**/
+mod_export int
+callhookfunc(char *name, LinkList lnklst)
+{
+    Eprog prog;
+
+    if ((prog = getshfunc(name)) != &dummy_eprog) {
+	/*
+	 * Save stopmsg, since user doesn't get a chance to respond
+	 * to a list of jobs generated in a hook.
+	 */
+	int osc = sfcontext, osm = stopmsg;
+
+	sfcontext = SFC_HOOK;
+	doshfunc(name, prog, lnklst, 0, 1);
+	sfcontext = osc;
+	stopmsg = osm;
+
+	return 0;
+    }
+
+    return 1;
+}
+
 /* do pre-prompt stuff */
 
 /**/
@@ -632,7 +656,6 @@ preprompt(void)
 {
     static time_t lastperiodic;
     LinkNode ln;
-    Eprog prog;
     int period = getiparam("PERIOD");
     int mailcheck = getiparam("MAILCHECK");
 
@@ -645,18 +668,7 @@ preprompt(void)
 
     /* If a shell function named "precmd" exists, *
      * then execute it.                           */
-    if ((prog = getshfunc("precmd")) != &dummy_eprog) {
-	/*
-	 * Save stopmsg, since user doesn't get a chance to respond
-	 * to a list of jobs generated in precmd.
-	 */
-	int osc = sfcontext, osm = stopmsg;
-
-	sfcontext = SFC_HOOK;
-	doshfunc("precmd", prog, NULL, 0, 1);
-	sfcontext = osc;
-	stopmsg = osm;
-    }
+    callhookfunc("precmd", NULL);
     if (errflag)
 	return;
 
@@ -664,14 +676,8 @@ preprompt(void)
      * "periodic" exists, 3) it's been greater than PERIOD since we *
      * executed "periodic", then execute it now.                    */
     if (period && (time(NULL) > lastperiodic + period) &&
-	(prog = getshfunc("periodic")) != &dummy_eprog) {
-	int osc = sfcontext;
-
-	sfcontext = SFC_HOOK;
-	doshfunc("periodic", prog, NULL, 0, 1);
-	sfcontext = osc;
+	!callhookfunc("periodic", NULL))
 	lastperiodic = time(NULL);
-    }
     if (errflag)
 	return;