about summary refs log tree commit diff
path: root/Src/signals.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-09-16 15:02:01 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-09-16 15:02:01 +0000
commit2920c227d3f8e6d8af1f2b0c3163badb95cde9b5 (patch)
tree854021a4e3cfa7a72bf67a364ce55e6803ca800b /Src/signals.c
parent14905ddc74f78b54c75434c8a4d7e029b1933280 (diff)
downloadzsh-2920c227d3f8e6d8af1f2b0c3163badb95cde9b5.tar.gz
zsh-2920c227d3f8e6d8af1f2b0c3163badb95cde9b5.tar.xz
zsh-2920c227d3f8e6d8af1f2b0c3163badb95cde9b5.zip
25677: add %x and %I prompt escapes for shell source code debugging
tidy up interface to doshfunc()
Diffstat (limited to 'Src/signals.c')
-rw-r--r--Src/signals.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/Src/signals.c b/Src/signals.c
index b794f1527..ba5777524 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -963,8 +963,7 @@ endtrapscope(void)
     }
 
     if (exittr) {
-	dotrapargs(SIGEXIT, &exittr, (exittr & ZSIG_FUNC) ?
-		   ((Shfunc)exitfn)->funcdef : (Eprog) exitfn);
+	dotrapargs(SIGEXIT, &exittr, exitfn);
 	if (exittr & ZSIG_FUNC)
 	    shfunctab->freenode((HashNode)exitfn);
 	else
@@ -1077,8 +1076,16 @@ int intrap;
 /**/
 int trapisfunc;
 
+/*
+ * sig is the signal number.
+ * *sigtr is the value to be taken as the field in sigtrapped (since
+ *   that may have changed by this point if we are exiting).
+ * sigfn is an Eprog with a non-function eval list, or a Shfunc
+ *   with a function trap.  It may be NULL with an ignored signal.
+ */
+
 /**/
-void
+static void
 dotrapargs(int sig, int *sigtr, void *sigfn)
 {
     LinkList args;
@@ -1153,7 +1160,7 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
 	trapisfunc = isfunc = 1;
 
 	sfcontext = SFC_SIGNAL;
-	doshfunc(name, sigfn, args, 0, 1);
+	doshfunc((Shfunc)sigfn, args, 0, 1);
 	sfcontext = osc;
 	freelinklist(args, (FreeFunc) NULL);
 	zsfree(name);
@@ -1162,7 +1169,7 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
 	trap_state = TRAP_STATE_PRIMED;
 	trapisfunc = isfunc = 0;
 
-	execode(sigfn, 1, 0);
+	execode((Eprog)sigfn, 1, 0);
     }
     runhookdef(AFTERTRAPHOOK, NULL);
 
@@ -1215,12 +1222,12 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
 void
 dotrap(int sig)
 {
-    Eprog funcprog;
+    void *funcprog;
 
     if (sigtrapped[sig] & ZSIG_FUNC) {
 	HashNode hn = gettrapnode(sig, 0);
 	if (hn)
-	    funcprog = ((Shfunc)hn)->funcdef;
+	    funcprog = hn;
 	else {
 #ifdef DEBUG
 	    dputs("BUG: running function trap which has escaped.");
@@ -1230,7 +1237,11 @@ dotrap(int sig)
     } else
 	funcprog = siglists[sig];
 
-    /* Copied from dotrapargs(). */
+    /*
+     * Copied from dotrapargs().
+     * (In fact, the gain from duplicating this appears to be virtually
+     * zero.  Not sure why it's here.)
+     */
     if ((sigtrapped[sig] & ZSIG_IGNORED) || !funcprog || errflag)
 	return;