X-Git-Url: http://git.subgeniuskitty.com/pforth/.git/blobdiff_plain/bb6b2dcdd9acffabfd373c4c3f6b64a9cc43f335..970d32b553a44051cedd2caf34267b7b1cdbab78:/csrc/pf_main.c diff --git a/csrc/pf_main.c b/csrc/pf_main.c index 9d8568d..6b07f33 100644 --- a/csrc/pf_main.c +++ b/csrc/pf_main.c @@ -43,13 +43,21 @@ #define TRUE (1) #define FALSE (0) #endif + +static const char *gErrorMsg32Bit = "ERROR - A long is not 4 bytes. Are we running on a 64-bit machine?!\n"; #ifdef PF_EMBEDDED int main( void ) { char IfInit = 0; const char *DicName = NULL; - const char *SourceName = NULL; + const char *SourceName = NULL; + // Check to make sure we are running in 32-bit mode. + if( sizeof(long) != 4 ) + { + pfMessage(gErrorMsg32Bit); + return 1; + } pfMessage("\npForth Embedded\n"); return pfDoForth( DicName, SourceName, IfInit); } @@ -68,7 +76,14 @@ int main( int argc, char **argv ) char *s; int32 i; int Result; - + + // Check to make sure we are running in 32-bit mode. + if( sizeof(long) != 4 ) + { + ERR((gErrorMsg32Bit)); + return 1; + } + /* For Metroworks on Mac */ #ifdef __MWERKS__ argc = ccommand(&argv); @@ -90,13 +105,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"));