From: Bill Lash Date: Sat, 27 Jul 2019 02:41:39 +0000 (-0500) Subject: Merge branch 'master' of https://gitlab.com/DavidGriffith/frotz X-Git-Url: https://scope-eye.net/git/?a=commitdiff_plain;h=29eed783a232cd30cfa987c2c359270c0469136e;p=liskon_frotz.git Merge branch 'master' of https://gitlab.com/DavidGriffith/frotz --- 29eed783a232cd30cfa987c2c359270c0469136e diff --cc src/curses/ux_init.c index f09c80c,1c6b5d6..dff3e23 --- a/src/curses/ux_init.c +++ b/src/curses/ux_init.c @@@ -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 ) diff --cc src/dumb/dumb_blorb.c index 4227c9c,267a4f0..1404417 --- a/src/dumb/dumb_blorb.c +++ b/src/dumb/dumb_blorb.c @@@ -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; } diff --cc src/dumb/dumb_init.c index 3214cdc,8628969..c1d4e2a --- a/src/dumb/dumb_init.c +++ b/src/dumb/dumb_init.c @@@ -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 )