diff --git a/interpreter.h b/interpreter.h index c74e7f2..8fe6d7c 100644 --- a/interpreter.h +++ b/interpreter.h @@ -445,7 +445,12 @@ struct Picoc_Struct const char *VersionString; /* exit longjump buffer */ +#if defined(UNIX_HOST) || defined(WIN32) jmp_buf PicocExitBuf; +#endif +#ifdef SURVEYOR_HOST + int PicocExitBuf[41]; +#endif /* string table */ struct Table StringTable; diff --git a/parse.c b/parse.c index bd18cfe..72b6d67 100644 --- a/parse.c +++ b/parse.c @@ -883,7 +883,7 @@ void PicocParseInteractiveNoStartPrompt(Picoc *pc, int EnableDebugger) enum ParseResult Ok; LexInitParser(&Parser, pc, NULL, NULL, pc->StrEmpty, TRUE, EnableDebugger); - PicocPlatformSetExitPoint(); + PicocPlatformSetExitPoint(pc); LexInteractiveClear(pc, &Parser); do diff --git a/picoc.c b/picoc.c index c8bd3ed..19715ff 100644 --- a/picoc.c +++ b/picoc.c @@ -44,7 +44,7 @@ int main(int argc, char **argv) } else { - if (PicocPlatformSetExitPoint()) + if (PicocPlatformSetExitPoint(&pc)) { PicocCleanup(&pc); return pc.PicocExitValue; diff --git a/picoc.h b/picoc.h index 5b3395e..2ac0f06 100644 --- a/picoc.h +++ b/picoc.h @@ -22,18 +22,15 @@ #if defined(UNIX_HOST) || defined(WIN32) #include -/* mark where to end the program for platforms which require this */ -extern jmp_buf PicocExitBuf; - /* this has to be a macro, otherwise errors will occur due to the stack being corrupt */ -#define PicocPlatformSetExitPoint() setjmp(PicocExitBuf) +#define PicocPlatformSetExitPoint(pc) setjmp((pc)->PicocExitBuf) #endif #ifdef SURVEYOR_HOST /* mark where to end the program for platforms which require this */ extern int PicocExitBuf[]; -#define PicocPlatformSetExitPoint() setjmp(PicocExitBuf) +#define PicocPlatformSetExitPoint(pc) setjmp((pc)->PicocExitBuf) #endif /* parse.c */