DUMB FROTZ: Fix syntax and version. Fix defines.h and git_hash.h. Fix long option...
authorDavid Griffith <dave@661.org>
Wed, 22 Feb 2017 12:24:59 +0000 (04:24 -0800)
committerDavid Griffith <dave@661.org>
Wed, 22 Feb 2017 12:28:35 +0000 (04:28 -0800)
The zgetopt() function will throw an error if you attempt to use a long
option flag like --this.  So I'm including "-" in the third parameter to
zgetopt() to cause long option flags to be ignored.

Makefile
src/dumb/dumb_init.c

index 83987a76d901790ec3ffe6fa41da53056c54b46c..f374df66fa79fe70d9da209fc57ccab9df61c20d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -173,8 +173,8 @@ else
        @echo "Invalid sound choice $(SOUND)."
 endif
 
-
-d$(NAME):              $(COMMON_TARGET) $(DUMB_TARGET)
+dumb:          d$(NAME)
+d$(NAME):      hash $(COMMON_DIR)/defines.h $(COMMON_TARGET) $(DUMB_TARGET)
        $(CC) -o d$(BINNAME)$(EXTENSION) $(COMMON_TARGET) $(DUMB_TARGET) $(LIB)
 
 all:   $(NAME) d$(NAME)
index dec3ac855522c8eb31ea15d2e95911042c93d2da..108b961217e271f74ffa835f84040eb3853c5633 100644 (file)
 f_setup_t f_setup;
 
 static char *my_strdup(char *);
+static void print_version(void);
 
 #define INFORMATION "\
 An interpreter for all Infocom and other Z-Machine games.\n\
-Complies with standard 1.0 of Graham Nelson's specification.\n\
 \n\
 Syntax: dfrotz [options] story-file\n\
-  -a   watch attribute setting \t -r xxx  do runtime setting \\xxx\n\
-  -A   watch attribute testing \t    before starting (can be used repeatedly)\n\
-  -h # screen height           \t -R <filename> load this save file\n\
-  -i   ignore fatal errors     \t -s # random number seed value\n\
-  -I # interpreter number      \t -S # transcript width\n\
-  -o   watch object movement   \t -t   set Tandy bit\n\
-  -O   watch object locating   \t -u # slots for multiple undo\n\
-  -p   plain ASCII output only \t -w # screen width\n\
-  -P   alter piracy opcode     \t -x   expand abbreviations g/x/z"
+  -a   watch attribute setting  \t -R <filename> load this save file\n\
+  -A   watch attribute testing  \t -s # random number seed value\n\
+  -h # screen height            \t -S # transcript width\n\
+  -i   ignore fatal errors         \t -t   set Tandy bit\n\
+  -I # interpreter number          \t -u # slots for multiple undo\n\
+  -o   watch object movement       \t -v show version information\n\
+  -O   watch object locating       \t -w # screen width\n\
+  -p   plain ASCII output only     \t -x   expand abbreviations g/x/z\n\
+  -P   alter piracy opcode \n\
+  -r xxx set runtime option \\xxx before starting (can be used repeatedly)\n"
 
 /* A unix-like getopt, but with the names changed to avoid any problems.  */
 static int zoptind = 1;
@@ -78,7 +79,7 @@ void os_process_arguments(int argc, char *argv[])
     do_more_prompts = TRUE;
     /* Parse the options */
     do {
-       c = zgetopt(argc, argv, "aAh:iI:moOpPs:r:R:S:tu:w:xZ:");
+       c = zgetopt(argc, argv, "-aAh:iI:moOpPs:r:R:S:tu:vw:xZ:");
        switch(c) {
          case 'a': f_setup.attribute_assignment = 1; break;
          case 'A': f_setup.attribute_testing = 1; break;
@@ -98,6 +99,7 @@ void os_process_arguments(int argc, char *argv[])
          case 'S': f_setup.script_cols = atoi(zoptarg); break;
        case 't': user_tandy_bit = 1; break;
          case 'u': f_setup.undo_slots = atoi(zoptarg); break;
+       case 'v': print_version(); exit(2); break;
        case 'w': user_screen_width = atoi(zoptarg); break;
          case 'x': f_setup.expand_abbreviations = 1; break;
          case 'Z': f_setup.err_report_mode = atoi(zoptarg);
@@ -109,7 +111,7 @@ void os_process_arguments(int argc, char *argv[])
     } while (c != EOF);
 
     if (((argc - zoptind) != 1) && ((argc - zoptind) != 2)) {
-       printf("FROTZ V%s\tdumb interface.\n", VERSION);
+       printf("FROTZ V%s\tDumb interface.\n", VERSION);
        puts(INFORMATION);
        printf("\t-Z # error checking mode (default = %d)\n"
            "\t     %d = don't report errors   %d = report first error\n"
@@ -250,3 +252,20 @@ char *my_strdup(char *src)
        *p = '\0';
        return str;
 }
+
+
+static void print_version(void)
+{
+    printf("FROTZ V%s\t", VERSION);
+    printf("Dumb interface.\n");
+    printf("Git commit:\t%s\n", GIT_HASH);
+    printf("Git tag:\t%s\n", GIT_TAG);
+    printf("Git branch:\t%s\n", GIT_BRANCH);
+    printf("  Frotz was originally written by Stefan Jokisch.\n");
+    printf("  It complies with standard 1.0 of Graham Nelson's specification.\n");
+    printf("  It was ported to Unix by Galen Hazelwood.\n");
+    printf("  The core and dumb port are currently maintained by David Griffith.\n");
+    printf("  See https://github.com/DavidGriffith/frotz for Frotz's homepage.\n\n");
+    return;
+}
+