}\r
\r
/**************************************************************************\r
-** Main entry point fo pForth\r
+** Main entry point for pForth\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
#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
\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
TOUCH(IfInit);\r
#endif /* !PF_NO_INIT && !PF_NO_SHELL*/\r
{\r
- if( DicName )\r
+ if( DicFileName )\r
{\r
- pfDebugMessage("DicName = "); pfDebugMessage(DicName); pfDebugMessage("\n");\r
+ pfDebugMessage("DicFileName = "); pfDebugMessage(DicFileName); pfDebugMessage("\n");\r
EMIT_CR;\r
- dic = pfLoadDictionary( DicName, &EntryPoint );\r
+ dic = pfLoadDictionary( DicFileName, &EntryPoint );\r
}\r
else\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
if( Result != 0 )\r
{\r
MSG("Error in AUTO.INIT");\r
- goto error;\r
+ goto error2;\r
}\r
-\r
+ \r
if( EntryPoint != 0 )\r
{\r
Result = pfCatch( EntryPoint );\r
\r
return Result;\r
\r
-error:\r
+error2:\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
IfInit = TRUE;\r
DicName = NULL;\r
break;\r
+ \r
case 'q':\r
pfSetQuiet( TRUE );\r
break;\r
+ \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
+ \r
default:\r
ERR(("Unrecognized option!\n"));\r
ERR(("pforth {-i} {-q} {-dfilename.dic} {sourcefilename}\n"));\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
\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