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