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:
parent
fc164556fb
commit
57766aa28f
15
picoc.c
15
picoc.c
|
@ -60,8 +60,9 @@ int main(int argc, char **argv)
|
|||
# ifdef SURVEYOR_HOST
|
||||
# define HEAP_SIZE C_HEAPSIZE
|
||||
# include <setjmp.h>
|
||||
|
||||
extern int ExitBuf[];
|
||||
# include "../srv.h"
|
||||
# include "../print.h"
|
||||
# include "../string.h"
|
||||
|
||||
int picoc(char *SourceStr)
|
||||
{
|
||||
|
@ -80,12 +81,12 @@ int picoc(char *SourceStr)
|
|||
}
|
||||
}
|
||||
|
||||
ExitBuf[40] = 0;
|
||||
setjmp(ExitBuf);
|
||||
if (ExitBuf[40]) {
|
||||
PicocExitBuf[40] = 0;
|
||||
setjmp(PicocExitBuf);
|
||||
if (PicocExitBuf[40]) {
|
||||
printf("Leaving PicoC\n\r");
|
||||
PicocCleanup();
|
||||
return ExitValue;
|
||||
return PicocExitValue;
|
||||
}
|
||||
|
||||
if (SourceStr)
|
||||
|
@ -94,7 +95,7 @@ int picoc(char *SourceStr)
|
|||
PicocParseInteractive();
|
||||
PicocCleanup();
|
||||
|
||||
return ExitValue;
|
||||
return PicocExitValue;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
|
6
picoc.h
6
picoc.h
|
@ -25,6 +25,12 @@ extern jmp_buf PicocExitBuf;
|
|||
#define PicocPlatformSetExitPoint() setjmp(PicocExitBuf)
|
||||
#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 */
|
||||
void PicocParse(const char *FileName, const char *Source, int SourceLen, int RunIt, int CleanupNow, int CleanupSource);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "../interpreter.h"
|
||||
#include "../picoc.h"
|
||||
|
||||
static int Blobcnt, Blobx1, Blobx2, Bloby1, Bloby2, Iy1, Iy2, Iu1, Iu2, Iv1, Iv2;
|
||||
static int Cxmin, Cxmax, Cymin, Cymax;
|
||||
|
@ -850,8 +851,8 @@ void Cautorun (struct ParseState *Parser, struct Value *ReturnValue, struct Valu
|
|||
if (getchar(&ch)) {
|
||||
if (ch == 0x1B) { // if ESC found, exit picoC
|
||||
printf("found ESC\r\n");
|
||||
ExitBuf[40] = 1;
|
||||
longjmp(ExitBuf, 1);
|
||||
PicocExitBuf[40] = 1;
|
||||
longjmp(PicocExitBuf, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#include "../interpreter.h"
|
||||
#include "../picoc.h"
|
||||
|
||||
/* mark where to end the program for platforms which require this */
|
||||
int PicocExitBuf[41];
|
||||
|
||||
/* deallocate any storage */
|
||||
void PlatformCleanup()
|
||||
|
@ -11,12 +14,12 @@ char *PlatformGetLine(char *Buf, int MaxLen, const char *Prompt)
|
|||
{
|
||||
int ix;
|
||||
char ch, *cp;
|
||||
|
||||
|
||||
printf(Prompt);
|
||||
|
||||
|
||||
ix = 0;
|
||||
cp = 0;
|
||||
|
||||
|
||||
// If the first character is \n or \r, eat it
|
||||
ch = getch();
|
||||
if (ch == '\n' || ch == '\r')
|
||||
|
@ -24,10 +27,11 @@ char *PlatformGetLine(char *Buf, int MaxLen, const char *Prompt)
|
|||
// And get the next character
|
||||
ch = getch();
|
||||
}
|
||||
|
||||
|
||||
while (ix++ < MaxLen) {
|
||||
|
||||
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;
|
||||
}
|
||||
if (ch == '\n') {
|
||||
|
@ -57,14 +61,11 @@ int PlatformGetCharacter()
|
|||
return getch();
|
||||
}
|
||||
|
||||
/* mark where to end the program for platforms which require this */
|
||||
int ExitBuf[41];
|
||||
|
||||
/* exit the program */
|
||||
void PlatformExit(int RetVal)
|
||||
{
|
||||
ExitValue = RetVal;
|
||||
ExitBuf[40] = 1;
|
||||
longjmp(ExitBuf, 1);
|
||||
PicocExitValue = RetVal;
|
||||
PicocExitBuf[40] = 1;
|
||||
longjmp(PicocExitBuf, 1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue