From: Phil Burk Date: Sat, 25 May 2019 23:21:25 +0000 (-0700) Subject: hmsl: support EOT to force BYE X-Git-Url: http://git.subgeniuskitty.com/pforth/.git/commitdiff_plain/2d8c3ec4828a9a6502a3b81334e1b50294d26fcc hmsl: support EOT to force BYE Force Forth to exit when an ASCII EOT character is received. Also fix some indentation. --- diff --git a/csrc/pf_core.c b/csrc/pf_core.c index a6d7c26..73ab1ff 100644 --- a/csrc/pf_core.c +++ b/csrc/pf_core.c @@ -39,18 +39,18 @@ ** Global Data ***************************************************************/ -char gScratch[TIB_SIZE]; +char gScratch[TIB_SIZE]; pfTaskData_t *gCurrentTask = NULL; pfDictionary_t *gCurrentDictionary; -cell_t gNumPrimitives; +cell_t gNumPrimitives; -ExecToken gLocalCompiler_XT; /* custom compiler for local variables */ -ExecToken gNumberQ_XT; /* XT of NUMBER? */ -ExecToken gQuitP_XT; /* XT of (QUIT) */ -ExecToken gAcceptP_XT; /* XT of ACCEPT */ +ExecToken gLocalCompiler_XT; /* custom compiler for local variables */ +ExecToken gNumberQ_XT; /* XT of NUMBER? */ +ExecToken gQuitP_XT; /* XT of (QUIT) */ +ExecToken gAcceptP_XT; /* XT of ACCEPT */ /* Depth of data stack when colon called. */ -cell_t gDepthAtColon; +cell_t gDepthAtColon; /* Global Forth variables. */ cell_t gVarContext; /* Points to last name field. */ @@ -64,8 +64,8 @@ cell_t gVarQuiet; /* Suppress unnecessary messages, OK, etc. */ cell_t gVarReturnCode; /* Returned to caller of Forth, eg. UNIX shell. */ /* data for INCLUDE that allows multiple nested files. */ -IncludeFrame gIncludeStack[MAX_INCLUDE_DEPTH]; -cell_t gIncludeIndex; +IncludeFrame gIncludeStack[MAX_INCLUDE_DEPTH]; +cell_t gIncludeIndex; static void pfResetForthTask( void ); static void pfInit( void ); diff --git a/csrc/pf_inner.c b/csrc/pf_inner.c index 97fb004..1446356 100644 --- a/csrc/pf_inner.c +++ b/csrc/pf_inner.c @@ -49,6 +49,7 @@ #define M_DUP PUSH_TOS; #define M_DROP { TOS = M_POP; } +#define ASCII_EOT (0x04) /*************************************************************** ** Macros for Floating Point stack access. @@ -1264,6 +1265,9 @@ DBUG(("XX ah,m,l = 0x%8x,%8x,%8x - qh,l = 0x%8x,%8x\n", ah,am,al, qh,ql )); case ID_KEY: PUSH_TOS; TOS = ioKey(); + if (TOS == ASCII_EOT) { + M_THROW(THROW_BYE); + } endcase; #ifndef PF_NO_SHELL diff --git a/csrc/pfcompil.c b/csrc/pfcompil.c index 937e39e..a3f44f3 100644 --- a/csrc/pfcompil.c +++ b/csrc/pfcompil.c @@ -1158,7 +1158,11 @@ cell_t ffRefill( void ) /* ACCEPT is deferred so we call it through the dictionary. */ PUSH_DATA_STACK( gCurrentTask->td_SourcePtr ); PUSH_DATA_STACK( TIB_SIZE ); - pfCatch( gAcceptP_XT ); + ThrowCode throwCode = pfCatch( gAcceptP_XT ); + if (throwCode) { + Result = throwCode; + goto error; + } Num = POP_DATA_STACK; if( Num < 0 ) {