hmsl: support EOT to force BYE
authorPhil Burk <philburk@mobileer.com>
Sat, 25 May 2019 23:21:25 +0000 (16:21 -0700)
committerPhil Burk <philburk@mobileer.com>
Sat, 25 May 2019 23:21:25 +0000 (16:21 -0700)
Force Forth to exit when an ASCII EOT character is received.
Also fix some indentation.

csrc/pf_core.c
csrc/pf_inner.c
csrc/pfcompil.c

index a6d7c26..73ab1ff 100644 (file)
 ** 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 );
index 97fb004..1446356 100644 (file)
@@ -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
index 937e39e..a3f44f3 100644 (file)
@@ -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 )
         {