Fix Saushev spelling, allow space after -d, restore tty mode after dic loading error.
[pforth] / csrc / pf_main.c
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