From 24b47c58f4018a46dd9f7dad7b94a6294ffd30a6 Mon Sep 17 00:00:00 2001 From: "zik.saleeba" Date: Sun, 1 Mar 2009 10:07:01 +0000 Subject: [PATCH] Added changes from Howard git-svn-id: http://picoc.googlecode.com/svn/trunk@135 21eae674-98b7-11dd-bd71-f92a316d2d60 --- picoc.c | 21 ++++++++++++++------- platform.h | 2 +- platform_support.c | 19 +++++++++++++++---- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/picoc.c b/picoc.c index c8cc33a..1272b45 100644 --- a/picoc.c +++ b/picoc.c @@ -38,14 +38,21 @@ for (Count = 1; Count <= 10; Count++)\n\ printf(\"%d\n\", Count);\n\ "; +int errjmp[41]; + int picoc() -{ - Initialise(); - if (PlatformSetExitPoint()) - return 1; - - Parse("test.c", SourceStr, strlen(SourceStr), TRUE); - return 0; +{ + Initialise(); + + errjmp[40] = 0; + setjmp(errjmp); + if (errjmp[40]) { + printf("\n\rgoodbye ...\n\r"); + return 1; + } + + Parse("test.c", SourceStr, strlen(SourceStr), TRUE); + return 0; } # endif #endif diff --git a/platform.h b/platform.h index 606feb0..6af012a 100644 --- a/platform.h +++ b/platform.h @@ -44,7 +44,7 @@ # define NO_CTYPE # include "../string.h" # include "../print.h" -# include "../malloc.h" +# include "../srv.h" # include "../setjmp.h" # include "../stdarg.h" # define assert(x) diff --git a/platform_support.c b/platform_support.c index 5c29fac..2e2eedc 100644 --- a/platform_support.c +++ b/platform_support.c @@ -65,25 +65,36 @@ void PlatformExit() /* get a line of interactive input */ char *PlatformGetLine(char *Buf, int MaxLen) { - return NULL; + return NULL; } /* write a character to the console */ void PlatformPutc(unsigned char OutCh) { + putchar(OutCh); } /* mark where to end the program for platforms which require this */ -static jmp_buf ExitPoint; +int errjmp[41]; + 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 */ +extern int errjmp[]; + void PlatformExit() { - longjmp(ExitPoint, 1); + errjmp[40] = 1; + longjmp(errjmp, 1); } #endif