Skip to content

Commit aee094c

Browse files
committed
Added finalization routines.
1 parent 08c1661 commit aee094c

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

Parser/acceler.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,26 @@ PyGrammar_AddAccelerators(g)
6868
#endif
6969
}
7070

71+
void
72+
PyGrammar_RemoveAccelerators(g)
73+
grammar *g;
74+
{
75+
dfa *d;
76+
int i;
77+
g->g_accel = 0;
78+
d = g->g_dfa;
79+
for (i = g->g_ndfas; --i >= 0; d++) {
80+
state *s;
81+
int j;
82+
s = d->d_state;
83+
for (j = 0; j < d->d_nstates; j++, s++) {
84+
if (s->s_accel)
85+
PyMem_DEL(s->s_accel);
86+
s->s_accel = NULL;
87+
}
88+
}
89+
}
90+
7191
static void
7292
fixdfa(g, d)
7393
grammar *g;

Parser/intrcheck.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ PyOS_InitInterrupts()
4949
{
5050
}
5151

52+
void
53+
PyOS_FiniInterrupts()
54+
{
55+
}
56+
5257
int
5358
PyOS_InterruptOccurred()
5459
{
@@ -81,6 +86,11 @@ PyOS_InitInterrupts()
8186
_go32_want_ctrl_break(1 /* TRUE */);
8287
}
8388

89+
void
90+
PyOS_FiniInterrupts()
91+
{
92+
}
93+
8494
int
8595
PyOS_InterruptOccurred()
8696
{
@@ -96,6 +106,11 @@ PyOS_InitInterrupts()
96106
{
97107
}
98108

109+
void
110+
PyOS_FiniInterrupts()
111+
{
112+
}
113+
99114
int
100115
PyOS_InterruptOccurred()
101116
{
@@ -170,10 +185,12 @@ intcatcher(sig)
170185
Py_AddPendingCall(PyErr_CheckSignals, NULL);
171186
}
172187

188+
static RETSIGTYPE (*old_siginthandler)() = SIG_DFL;
189+
173190
void
174191
PyOS_InitInterrupts()
175192
{
176-
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
193+
if ((old_siginthandler = signal(SIGINT, SIG_IGN)) != SIG_IGN)
177194
signal(SIGINT, intcatcher);
178195
#ifdef HAVE_SIGINTERRUPT
179196
/* This is for SunOS and other modern BSD derivatives.
@@ -186,6 +203,12 @@ PyOS_InitInterrupts()
186203
#endif /* HAVE_SIGINTERRUPT */
187204
}
188205

206+
void
207+
PyOS_FiniInterrupts()
208+
{
209+
signal(SIGINT, old_siginthandler);
210+
}
211+
189212
int
190213
PyOS_InterruptOccurred()
191214
{

0 commit comments

Comments
 (0)