1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-02 22:11:54 +02:00

11906: yet two more saving trap bugs

This commit is contained in:
Peter Stephenson 2000-06-14 22:00:39 +00:00
parent 545c064770
commit a777f021a2
2 changed files with 20 additions and 8 deletions

View file

@ -1,3 +1,9 @@
2000-06-14 Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
* 11906: Src/signals.c: yet another two bugs with saving traps:
flags were prematurely restored when resetting and TRAPEXIT
was sometimes saved incorrectly when exitting the scope.
2000-06-14 Oliver Kiddle <opk@zsh.org>
* 11903: Completion/Core/_expand: handle suffix style for arrays

View file

@ -642,6 +642,7 @@ struct savetrap {
};
static LinkList savetraps;
static int dontsavetrap;
/*
* Save the current trap by copying it. This does nothing to
@ -670,6 +671,10 @@ dosavetrap(int sig, int level)
newshf->flags = shf->flags;
newshf->funcdef = dupeprog(shf->funcdef, 0);
}
#ifdef DEBUG
else dputs("BUG: no function present with function trap flag set.");
#endif
st->list = newshf;
} else if (sigtrapped[sig]) {
st->list = sigfuncs[sig] ? dupeprog(sigfuncs[sig], 0) : NULL;
@ -754,7 +759,8 @@ removetrap(int sig)
* one, to aid in removing this one. However, if there's
* already one at the current locallevel we just overwrite it.
*/
if ((isset(LOCALTRAPS) || sig == SIGEXIT) && locallevel &&
if (!dontsavetrap && (isset(LOCALTRAPS) || sig == SIGEXIT) &&
locallevel &&
(!trapped || locallevel > (sigtrapped[sig] >> ZSIG_SHIFT)))
dosavetrap(sig, locallevel);
@ -854,21 +860,19 @@ endtrapscope(void)
remnode(savetraps, ln);
if (sigtrapped[sig])
unsettrap(sig);
sigtrapped[sig] = st->flags;
if (st->flags && (st->list != NULL)) {
Eprog prog = (st->flags & ZSIG_FUNC) ?
((Shfunc) st->list)->funcdef : (Eprog) st->list;
/* prevent settrap from saving this */
int oldlt = opts[LOCALTRAPS];
opts[LOCALTRAPS] = 0;
dontsavetrap++;
settrap(sig, prog);
opts[LOCALTRAPS] = oldlt;
dontsavetrap--;
if ((sigtrapped[sig] = st->flags) & ZSIG_FUNC)
shfunctab->addnode(shfunctab, ((Shfunc)st->list)->nam,
(Shfunc) st->list);
}
} else if (sigtrapped[sig])
unsettrap(sig);
zfree(st, sizeof(*st));
}
}
@ -881,6 +885,8 @@ endtrapscope(void)
else
freeeprog(exitfn);
}
DPUTS(!locallevel && savetraps && firstnode(savetraps),
"BUG: still saved traps outside all function scope");
}
/* Execute a trap function for a given signal, possibly