From 5141e68daa20caa8523361d5dff63e9384c30191 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 22 Nov 2004 10:33:03 +0000 Subject: 20572: Allow alternative signal names --- Src/signals.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'Src/signals.c') 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); -- cgit 1.4.1