Merge branch 'master' of https://gitlab.com/DavidGriffith/frotz
authorBill Lash <william.lash@gmail.com>
Sat, 27 Jul 2019 02:41:39 +0000 (21:41 -0500)
committerBill Lash <william.lash@gmail.com>
Sat, 27 Jul 2019 02:41:39 +0000 (21:41 -0500)
1  2 
src/curses/ux_init.c
src/dumb/dumb_blorb.c
src/dumb/dumb_init.c

index f09c80c3e47b07dded27a616f3c08abb0d16d698,1c6b5d63e4e45f84f9432d83448a1e0192239b9b..dff3e231342b1149539f4a76c85778e8ba692161
@@@ -340,9 -340,9 +340,12 @@@ void os_process_arguments (int argc, ch
      f_setup.story_file = strdup(argv[zoptind]);
      f_setup.story_name = strdup(basename(argv[zoptind]));
  
 +    if (argv[optind+1] != NULL)
 +      f_setup.blorb_file = strdup(argv[optind+1]);
 +
+     if (argv[zoptind+1] != NULL)
+       f_setup.blorb_file = strdup(argv[zoptind+1]);
      /* Now strip off the extension */
      p = strrchr(f_setup.story_name, '.');
      if ( p != NULL )
index 4227c9c7049bd5da4ae570ab7e4890fcc87a99ac,267a4f0b238df8016662570a209368e4d2815d96..1404417e6b7105330095f7e6d87e69c8cb81358f
@@@ -77,41 -75,37 +75,40 @@@ bb_err_t dumb_blorb_init(char *filename
       */
      if (isblorb(fp)) {                        /* Now we know to look */
        f_setup.exec_in_blorb = 1;      /* for zcode in the blorb */
-         blorb_fp = fopen(filename, "rb");
+         blorb_fp = fp;
      } else {
-       len1 = strlen(filename) + strlen(EXT_BLORB);
-       len2 = strlen(filename) + strlen(EXT_BLORB3);
-       mystring = malloc(len2 * sizeof(char) + 1);
-         strncpy(mystring, filename, len1 * sizeof(char));
-       p = strrchr(mystring, '.');
-       if (p != NULL)
-           *p = '\0';
-         strncat(mystring, EXT_BLORB, len1 * sizeof(char));
-       /* Done monkeying with the initial file. */
        fclose(fp);
-       fp = NULL;
+       if (f_setup.blorb_file != NULL)
+           mystring = strdup(f_setup.blorb_file);
+       else {
+           len1 = strlen(filename) + strlen(EXT_BLORB);
+           len2 = strlen(filename) + strlen(EXT_BLORB3);
+           mystring = malloc(len2 * sizeof(char) + 1);
+           strncpy(mystring, filename, len1 * sizeof(char));
+           p = strrchr(mystring, '.');
+           if (p != NULL) *p = '\0';
+           strncat(mystring, EXT_BLORB, len1 * sizeof(char));
+       }
  
        /* Check if foo.blb is there. */
-       if (f_setup.blorb_file != NULL)
+       if ((fp = fopen(mystring, "rb")) == NULL) {
 -          p = strrchr(mystring, '.');
 +          mystring = strdup(f_setup.blorb_file);
 +      else {
-           if ((blorb_fp = fopen(mystring, "rb")) == NULL) {
 +              p = strrchr(mystring, '.');
-               if (p != NULL)
-                   *p = '\0';
-               strncat(mystring, EXT_BLORB3, len2 * sizeof(char));
-               blorb_fp = fopen(mystring, "rb");
+           if (p != NULL) *p = '\0';
+           strncat(mystring, EXT_BLORB3, len2 * sizeof(char));
 +          }
-       }
  
-       if (blorb_fp == NULL || !isblorb(fp))   /* No matching blorbs found. */
+           if (!(fp = fopen(mystring, "rb")))
+               return bb_err_NoBlorb;
+       }
+       if (!isblorb(fp)) {
+           fclose(fp);
            return bb_err_NoBlorb;
+       }
        /* At this point we know that we're using a naked zcode file */
        /* with resources in a separate Blorb file. */
+       blorb_fp = fp;
        f_setup.use_blorb = 1;
      }
  
index 3214cdce7dd070144d7fcc13ed415cc457c02f06,86289696acc049986e2b5eff4b149bed31f302b5..c1d4e2ad0614245ef867bfb3e36a19c67dd7f60a
@@@ -150,9 -149,9 +149,12 @@@ void os_process_arguments(int argc, cha
      f_setup.story_file = strdup(argv[zoptind]);
      f_setup.story_name = strdup(basename(argv[zoptind]));
  
 +    if (argv[optind+1] != NULL)
 +      f_setup.blorb_file = strdup(argv[optind+1]);
 +
+     if (argv[zoptind+1] != NULL)
+       f_setup.blorb_file = strdup(argv[zoptind+1]);
      /* Now strip off the extension */
      p = strrchr(f_setup.story_name, '.');
      if ( p != NULL )