Fix Saushev spelling, allow space after -d, restore tty mode after dic loading error.
authorphil@softsynth.com <phil@softsynth.com@b0a0988d-7f52-0410-8c73-4f6cdee1a2cf>
Mon, 16 Mar 2009 01:42:33 +0000 (01:42 +0000)
committerphil@softsynth.com <phil@softsynth.com@b0a0988d-7f52-0410-8c73-4f6cdee1a2cf>
Mon, 16 Mar 2009 01:42:33 +0000 (01:42 +0000)
csrc/pf_core.c
csrc/pf_main.c
releases.txt

index c2fc2c9..497b7e0 100644 (file)
@@ -427,9 +427,9 @@ void pfMessage( const char *CString )
 }\r
 \r
 /**************************************************************************\r
 }\r
 \r
 /**************************************************************************\r
-** Main entry point fo pForth\r
+** Main entry point for pForth\r
 */\r
 */\r
-int32 pfDoForth( const char *DicName, const char *SourceName, int32 IfInit )\r
+int32 pfDoForth( const char *DicFileName, const char *SourceName, int32 IfInit )\r
 {\r
        pfTaskData_t *cftd;\r
        pfDictionary_t *dic = NULL;\r
 {\r
        pfTaskData_t *cftd;\r
        pfDictionary_t *dic = NULL;\r
@@ -439,7 +439,7 @@ int32 pfDoForth( const char *DicName, const char *SourceName, int32 IfInit )
 \r
 #ifdef PF_USER_INIT\r
        Result = PF_USER_INIT;\r
 \r
 #ifdef PF_USER_INIT\r
        Result = PF_USER_INIT;\r
-       if( Result < 0 ) goto error;\r
+       if( Result < 0 ) goto error1;\r
 #endif\r
 \r
        pfInit();\r
 #endif\r
 \r
        pfInit();\r
@@ -473,7 +473,7 @@ int32 pfDoForth( const char *DicName, const char *SourceName, int32 IfInit )
 \r
 \r
 #ifdef PF_NO_GLOBAL_INIT\r
 \r
 \r
 #ifdef PF_NO_GLOBAL_INIT\r
-               if( LoadCustomFunctionTable() < 0 ) goto error; /* Init custom 'C' call array. */\r
+               if( LoadCustomFunctionTable() < 0 ) goto error2; /* Init custom 'C' call array. */\r
 #endif\r
 \r
 #if (!defined(PF_NO_INIT)) && (!defined(PF_NO_SHELL))\r
 #endif\r
 \r
 #if (!defined(PF_NO_INIT)) && (!defined(PF_NO_SHELL))\r
@@ -487,11 +487,11 @@ int32 pfDoForth( const char *DicName, const char *SourceName, int32 IfInit )
                TOUCH(IfInit);\r
 #endif /* !PF_NO_INIT && !PF_NO_SHELL*/\r
                {\r
                TOUCH(IfInit);\r
 #endif /* !PF_NO_INIT && !PF_NO_SHELL*/\r
                {\r
-                       if( DicName )\r
+                       if( DicFileName )\r
                        {\r
                        {\r
-                               pfDebugMessage("DicName = "); pfDebugMessage(DicName); pfDebugMessage("\n");\r
+                               pfDebugMessage("DicFileName = "); pfDebugMessage(DicFileName); pfDebugMessage("\n");\r
                                EMIT_CR;\r
                                EMIT_CR;\r
-                               dic = pfLoadDictionary( DicName, &EntryPoint );\r
+                               dic = pfLoadDictionary( DicFileName, &EntryPoint );\r
                        }\r
                        else\r
                        {\r
                        }\r
                        else\r
                        {\r
@@ -500,7 +500,7 @@ int32 pfDoForth( const char *DicName, const char *SourceName, int32 IfInit )
                                dic = pfLoadStaticDictionary();                 \r
                        }\r
                }\r
                                dic = pfLoadStaticDictionary();                 \r
                        }\r
                }\r
-               if( dic == NULL ) goto error;\r
+               if( dic == NULL ) goto error2;\r
                EMIT_CR;\r
 \r
                pfDebugMessage("pfDoForth: try AUTO.INIT\n");\r
                EMIT_CR;\r
 \r
                pfDebugMessage("pfDoForth: try AUTO.INIT\n");\r
@@ -508,9 +508,9 @@ int32 pfDoForth( const char *DicName, const char *SourceName, int32 IfInit )
                if( Result != 0 )\r
                {\r
                        MSG("Error in AUTO.INIT");\r
                if( Result != 0 )\r
                {\r
                        MSG("Error in AUTO.INIT");\r
-                       goto error;\r
+                       goto error2;\r
                }\r
                }\r
-\r
\r
                if( EntryPoint != 0 )\r
                {\r
                        Result = pfCatch( EntryPoint );\r
                if( EntryPoint != 0 )\r
                {\r
                        Result = pfCatch( EntryPoint );\r
@@ -550,8 +550,15 @@ int32 pfDoForth( const char *DicName, const char *SourceName, int32 IfInit )
        \r
        return Result;\r
        \r
        \r
        return Result;\r
        \r
-error:\r
+error2:\r
        MSG("pfDoForth: Error occured.\n");\r
        pfDeleteTask( cftd );\r
        MSG("pfDoForth: Error occured.\n");\r
        pfDeleteTask( cftd );\r
+       // Terminate so we restore normal shell tty mode.\r
+       pfTerm();\r
+\r
+#ifdef PF_USER_INIT\r
+error1:\r
+#endif\r
+\r
        return -1;\r
 }\r
        return -1;\r
 }\r
index 9d8568d..a779560 100644 (file)
@@ -90,13 +90,25 @@ int main( int argc, char **argv )
                                IfInit = TRUE;\r
                                DicName = NULL;\r
                                break;\r
                                IfInit = TRUE;\r
                                DicName = NULL;\r
                                break;\r
+                               \r
                        case 'q':\r
                                pfSetQuiet( TRUE );\r
                                break;\r
                        case 'q':\r
                                pfSetQuiet( TRUE );\r
                                break;\r
+                               \r
                        case 'd':\r
                                if( *s != '\0' ) DicName = s;\r
                        case 'd':\r
                                if( *s != '\0' ) DicName = s;\r
-                               else DicName = PF_DEFAULT_DICTIONARY;\r
+                               // Allow space after -d (Thanks Aleksej Saushev)\r
+                               // Make sure there is another argument.\r
+                               else if( (i+1) < argc )\r
+                               {\r
+                                       DicName = argv[++i];\r
+                               }\r
+                               if (DicName == NULL || *DicName == '\0')\r
+                               {\r
+                                       DicName = PF_DEFAULT_DICTIONARY;\r
+                               }\r
                                break;\r
                                break;\r
+                               \r
                        default:\r
                                ERR(("Unrecognized option!\n"));\r
                                ERR(("pforth {-i} {-q} {-dfilename.dic} {sourcefilename}\n"));\r
                        default:\r
                                ERR(("Unrecognized option!\n"));\r
                                ERR(("pforth {-i} {-q} {-dfilename.dic} {sourcefilename}\n"));\r
index 82b8c3d..f89773b 100644 (file)
@@ -2,6 +2,10 @@ Release History for pForth - a Portable ANS-like Forth written in ANSI 'C'
 \r
 Documentation for pForth at http://www.softsynth.com/pforth/\r
 \r
 \r
 Documentation for pForth at http://www.softsynth.com/pforth/\r
 \r
+V?? \r
+       - Allow space after -d command line option.\r
+       - Restore normal tty mode if pForth dictionary loading fails.\r
+        \r
 V24 2/20/09\r
        - Fixed Posix IO on Mac. ?TERMINAL was always returning true.\r
        - ACCCEPT now emits a space at end of line before output.\r
 V24 2/20/09\r
        - Fixed Posix IO on Mac. ?TERMINAL was always returning true.\r
        - ACCCEPT now emits a space at end of line before output.\r
@@ -9,7 +13,7 @@ V24 2/20/09
 \r
 V23 8/4/2008\r
        - Removed -v option from mkdir in build/unix/Makefile. It was not supported on FreeBSD.\r
 \r
 V23 8/4/2008\r
        - Removed -v option from mkdir in build/unix/Makefile. It was not supported on FreeBSD.\r
-         Thank you Alexsej Sauchdev for reporting this.\r
+         Thank you Alexsej Saushev for reporting this.\r
        \r
 V23  7/20/2008\r
     - Reorganized for Google Code project.\r
        \r
 V23  7/20/2008\r
     - Reorganized for Google Code project.\r