about summary refs log tree commit diff
path: root/Src/signals.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2004-11-22 10:33:03 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2004-11-22 10:33:03 +0000
commit5141e68daa20caa8523361d5dff63e9384c30191 (patch)
tree7521410b050a3f152e5dd902c209ff12477bd455 /Src/signals.c
parentf1846d402bed119a74409c3b417484661e100e27 (diff)
downloadzsh-5141e68daa20caa8523361d5dff63e9384c30191.tar.gz
zsh-5141e68daa20caa8523361d5dff63e9384c30191.tar.xz
zsh-5141e68daa20caa8523361d5dff63e9384c30191.zip
20572: Allow alternative signal names
Diffstat (limited to 'Src/signals.c')
-rw-r--r--Src/signals.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/Src/signals.c b/Src/signals.c
index fd5d47e71..9959d3c31 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -697,10 +697,8 @@ dosavetrap(int sig, int level)
 	 * Get the old function: this assumes we haven't added
 	 * the new one yet.
 	 */
-	char func[20];
 	Shfunc shf, newshf = NULL;
-	sprintf(func, "TRAP%s", sigs[sig]);
-	if ((shf = (Shfunc)shfunctab->getnode2(shfunctab, func))) {
+	if ((shf = (Shfunc)gettrapnode(sig, 1))) {
 	    /* Copy the node for saving */
 	    newshf = (Shfunc) zalloc(sizeof(*newshf));
 	    newshf->nam = ztrdup(shf->nam);
@@ -837,16 +835,15 @@ removetrap(int sig)
      * That causes a little inefficiency, but a good deal more reliability.
      */
     if (trapped & ZSIG_FUNC) {
-	char func[20];
-	HashNode node;
+	HashNode node = gettrapnode(sig, 1);
 
-	sprintf(func, "TRAP%s", sigs[sig]);
 	/*
 	 * As in dosavetrap(), don't call removeshfuncnode() because
 	 * that calls back into unsettrap();
 	 */
 	sigfuncs[sig] = NULL;
-	node = removehashnode(shfunctab, func);
+	if (node)
+	    removehashnode(shfunctab, node->nam);
 	unqueue_signals();
 
 	return node;
@@ -1010,10 +1007,10 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
     runhookdef(BEFORETRAPHOOK, NULL);
     if (*sigtr & ZSIG_FUNC) {
 	int osc = sfcontext;
+	HashNode hn = gettrapnode(sig, 0);
 
 	args = znewlinklist();
-	name = (char *) zalloc(5 + strlen(sigs[sig]));
-	sprintf(name, "TRAP%s", sigs[sig]);
+	name = ztrdup(hn->nam);
 	zaddlinknode(args, name);
 	sprintf(num, "%d", sig);
 	zaddlinknode(args, num);