Changes from Brian Schmalz to bring the surveyor platform back to a working state after I broke everything :)

git-svn-id: http://picoc.googlecode.com/svn/trunk@556 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2011-02-18 22:59:12 +00:00
parent fc164556fb
commit 57766aa28f
4 changed files with 29 additions and 20 deletions

15
picoc.c
View file

@ -60,8 +60,9 @@ int main(int argc, char **argv)
# ifdef SURVEYOR_HOST # ifdef SURVEYOR_HOST
# define HEAP_SIZE C_HEAPSIZE # define HEAP_SIZE C_HEAPSIZE
# include <setjmp.h> # include <setjmp.h>
# include "../srv.h"
extern int ExitBuf[]; # include "../print.h"
# include "../string.h"
int picoc(char *SourceStr) int picoc(char *SourceStr)
{ {
@ -80,12 +81,12 @@ int picoc(char *SourceStr)
} }
} }
ExitBuf[40] = 0; PicocExitBuf[40] = 0;
setjmp(ExitBuf); setjmp(PicocExitBuf);
if (ExitBuf[40]) { if (PicocExitBuf[40]) {
printf("Leaving PicoC\n\r"); printf("Leaving PicoC\n\r");
PicocCleanup(); PicocCleanup();
return ExitValue; return PicocExitValue;
} }
if (SourceStr) if (SourceStr)
@ -94,7 +95,7 @@ int picoc(char *SourceStr)
PicocParseInteractive(); PicocParseInteractive();
PicocCleanup(); PicocCleanup();
return ExitValue; return PicocExitValue;
} }
# endif # endif
#endif #endif

View file

@ -25,6 +25,12 @@ extern jmp_buf PicocExitBuf;
#define PicocPlatformSetExitPoint() setjmp(PicocExitBuf) #define PicocPlatformSetExitPoint() setjmp(PicocExitBuf)
#endif #endif
#ifdef SURVEYOR_HOST
/* mark where to end the program for platforms which require this */
extern int PicocExitBuf[];
#define PicocPlatformSetExitPoint() setjmp(PicocExitBuf)
#endif
/* parse.c */ /* parse.c */
void PicocParse(const char *FileName, const char *Source, int SourceLen, int RunIt, int CleanupNow, int CleanupSource); void PicocParse(const char *FileName, const char *Source, int SourceLen, int RunIt, int CleanupNow, int CleanupSource);

View file

@ -1,4 +1,5 @@
#include "../interpreter.h" #include "../interpreter.h"
#include "../picoc.h"
static int Blobcnt, Blobx1, Blobx2, Bloby1, Bloby2, Iy1, Iy2, Iu1, Iu2, Iv1, Iv2; static int Blobcnt, Blobx1, Blobx2, Bloby1, Bloby2, Iy1, Iy2, Iu1, Iu2, Iv1, Iv2;
static int Cxmin, Cxmax, Cymin, Cymax; static int Cxmin, Cxmax, Cymin, Cymax;
@ -850,8 +851,8 @@ void Cautorun (struct ParseState *Parser, struct Value *ReturnValue, struct Valu
if (getchar(&ch)) { if (getchar(&ch)) {
if (ch == 0x1B) { // if ESC found, exit picoC if (ch == 0x1B) { // if ESC found, exit picoC
printf("found ESC\r\n"); printf("found ESC\r\n");
ExitBuf[40] = 1; PicocExitBuf[40] = 1;
longjmp(ExitBuf, 1); longjmp(PicocExitBuf, 1);
} }
} }
} }

View file

@ -1,5 +1,8 @@
#include "../interpreter.h" #include "../interpreter.h"
#include "../picoc.h"
/* mark where to end the program for platforms which require this */
int PicocExitBuf[41];
/* deallocate any storage */ /* deallocate any storage */
void PlatformCleanup() void PlatformCleanup()
@ -26,8 +29,9 @@ char *PlatformGetLine(char *Buf, int MaxLen, const char *Prompt)
} }
while (ix++ < MaxLen) { while (ix++ < MaxLen) {
if (ch == 0x1B || ch == 0x03) { // ESC character or ctrl-c (to avoid problem with TeraTerm) - exit if (ch == 0x1B || ch == 0x03) { // ESC character or ctrl-c (to avoid problem with TeraTerm) - exit
printf("Leaving PicoC\n"); printf("Leaving PicoC\n");
return NULL; return NULL;
} }
if (ch == '\n') { if (ch == '\n') {
@ -57,14 +61,11 @@ int PlatformGetCharacter()
return getch(); return getch();
} }
/* mark where to end the program for platforms which require this */
int ExitBuf[41];
/* exit the program */ /* exit the program */
void PlatformExit(int RetVal) void PlatformExit(int RetVal)
{ {
ExitValue = RetVal; PicocExitValue = RetVal;
ExitBuf[40] = 1; PicocExitBuf[40] = 1;
longjmp(ExitBuf, 1); longjmp(PicocExitBuf, 1);
} }