Added changes from Howard

git-svn-id: http://picoc.googlecode.com/svn/trunk@135 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2009-03-01 10:07:01 +00:00
parent 7003b55ead
commit 24b47c58f4
3 changed files with 30 additions and 12 deletions

21
picoc.c
View file

@ -38,14 +38,21 @@ for (Count = 1; Count <= 10; Count++)\n\
printf(\"%d\n\", Count);\n\ printf(\"%d\n\", Count);\n\
"; ";
int errjmp[41];
int picoc() int picoc()
{ {
Initialise(); Initialise();
if (PlatformSetExitPoint())
return 1; errjmp[40] = 0;
setjmp(errjmp);
Parse("test.c", SourceStr, strlen(SourceStr), TRUE); if (errjmp[40]) {
return 0; printf("\n\rgoodbye ...\n\r");
return 1;
}
Parse("test.c", SourceStr, strlen(SourceStr), TRUE);
return 0;
} }
# endif # endif
#endif #endif

View file

@ -44,7 +44,7 @@
# define NO_CTYPE # define NO_CTYPE
# include "../string.h" # include "../string.h"
# include "../print.h" # include "../print.h"
# include "../malloc.h" # include "../srv.h"
# include "../setjmp.h" # include "../setjmp.h"
# include "../stdarg.h" # include "../stdarg.h"
# define assert(x) # define assert(x)

View file

@ -65,25 +65,36 @@ void PlatformExit()
/* get a line of interactive input */ /* get a line of interactive input */
char *PlatformGetLine(char *Buf, int MaxLen) char *PlatformGetLine(char *Buf, int MaxLen)
{ {
return NULL; return NULL;
} }
/* write a character to the console */ /* write a character to the console */
void PlatformPutc(unsigned char OutCh) void PlatformPutc(unsigned char OutCh)
{ {
putchar(OutCh);
} }
/* mark where to end the program for platforms which require this */ /* mark where to end the program for platforms which require this */
static jmp_buf ExitPoint; int errjmp[41];
int PlatformSetExitPoint() int PlatformSetExitPoint()
{ {
return setjmp(ExitPoint); errjmp[40] = 0;
setjmp(errjmp);
if (errjmp[40]) {
printf("\n\rgoodbye ...\n\r");
return 1;
}
return 0;
} }
/* exit the program */ /* exit the program */
extern int errjmp[];
void PlatformExit() void PlatformExit()
{ {
longjmp(ExitPoint, 1); errjmp[40] = 1;
longjmp(errjmp, 1);
} }
#endif #endif