Skip to content

Commit 8a76023

Browse files
committed
avoid setjmp/longjmp clobbering
1 parent ed51955 commit 8a76023

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

src/error.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -188,25 +188,9 @@ static Obj FuncPRINT_CURRENT_STATEMENT(Obj self, Obj stream, Obj context,
188188
Obj activeContext, Obj level,
189189
Obj totalDepth)
190190
{
191-
UInt levelInt = INT_INTOBJ(level);
192-
UInt totalDepthInt = INT_INTOBJ(totalDepth);
193-
UInt prefixWidth = 0;
194-
UInt levelWidth = 0;
195-
UInt i;
196-
197191
if (IsBottomLVars(context))
198192
return 0;
199193

200-
while (totalDepthInt > 0) {
201-
prefixWidth++;
202-
totalDepthInt /= 10;
203-
}
204-
i = levelInt;
205-
while (i > 0) {
206-
levelWidth++;
207-
i /= 10;
208-
}
209-
210194
// HACK: we want to redirect output
211195
// Try to print the output to stream. Use *errout* as a fallback.
212196
TypOutputFile output = { 0 };
@@ -224,6 +208,12 @@ static Obj FuncPRINT_CURRENT_STATEMENT(Obj self, Obj stream, Obj context,
224208
BOOL rethrow = FALSE;
225209
GAP_TRY
226210
{
211+
UInt levelInt = INT_INTOBJ(level);
212+
UInt totalDepthInt = INT_INTOBJ(totalDepth);
213+
UInt prefixWidth = 0;
214+
UInt levelWidth = 0;
215+
UInt i;
216+
227217
char prefix[32];
228218
Obj func = FUNC_LVARS(context);
229219
Obj funcname = NAME_FUNC(func);
@@ -232,7 +222,18 @@ static Obj FuncPRINT_CURRENT_STATEMENT(Obj self, Obj stream, Obj context,
232222
Stat call = STAT_LVARS(context);
233223
Obj body = BODY_FUNC(func);
234224
Obj filename = GET_FILENAME_BODY(body);
225+
226+
while (totalDepthInt > 0) {
227+
prefixWidth++;
228+
totalDepthInt /= 10;
229+
}
230+
235231
if (activeContext != Fail) {
232+
i = levelInt;
233+
while (i > 0) {
234+
levelWidth++;
235+
i /= 10;
236+
}
236237
snprintf(prefix, sizeof(prefix), "%c%*s[%lu] ",
237238
context == activeContext ? '*' : ' ',
238239
(int)(prefixWidth - levelWidth), "",

0 commit comments

Comments
 (0)