X-Git-Url: https://git.distorted.org.uk/~mdw/runlisp/blobdiff_plain/8996f767e047eefa8af4d01b1434b54f4c169b79..10427eb21d77a0edeb2f17e434515b91b420cdfb:/runlisp.c diff --git a/runlisp.c b/runlisp.c index 9ef809c..b2708d7 100644 --- a/runlisp.c +++ b/runlisp.c @@ -234,6 +234,17 @@ Evaluation mode:\n\ fp); } +/* Complain about options which aren't permitted as embedded options. */ +static void check_command_line(int ch) +{ + if ((flags&AF_STATEMASK) != AF_CMDLINE) { + moan("`%c%c' is not permitted as embedded option", + ch&OPTF_NEGATED ? '+' : '-', + ch&~OPTF_NEGATED); + flags |= AF_BOGUS; + } +} + /* Parse the options in the argument vector. */ static void parse_options(int argc, char *argv[]) { @@ -256,31 +267,39 @@ static void parse_options(int argc, char *argv[]) { 0, 0, 0, 0 } }; +#define FLAGOPT(ch, f, extra) \ + case ch: \ + extra \ + flags |= f; \ + break; \ + case ch | OPTF_NEGATED: \ + extra \ + flags &= ~f; \ + break +#define CMDL do { check_command_line(i); } while (0) + optarg = 0; optind = 0; optprog = (/*unconst*/ char *)progname; for (;;) { i = mdwopt(argc, argv, "+hVD+E+L:c:e:l:n+o:p:qv", opts, 0, 0, OPTF_NEGATION | OPTF_NOPROGNAME); if (i < 0) break; switch (i) { - case 'h': help(stdout); exit(0); - case 'V': version(stdout); exit(0); - case 'D': flags |= AF_VANILLA; break; - case 'D' | OPTF_NEGATED: flags &= ~AF_VANILLA; break; - case 'E': flags |= AF_NOEMBED; break; - case 'E' | OPTF_NEGATED: flags &= ~AF_NOEMBED; break; + case 'h': CMDL; help(stdout); exit(0); + case 'V': CMDL; version(stdout); exit(0); + FLAGOPT('D', AF_VANILLA, ; ); + FLAGOPT('E', AF_NOEMBED, { CMDL; }); case 'L': add_lispsys(optarg, "acceptable", &accept, LF_ACCEPT, offsetof(struct lispsys, next_accept)); break; - case 'c': read_config_path(optarg, 0); flags |= AF_SETCONF; break; - case 'e': push_eval_op('!', optarg); break; - case 'l': push_eval_op('<', optarg); break; - case 'n': flags |= AF_DRYRUN; break; - case 'n' | OPTF_NEGATED: flags &= ~AF_DRYRUN; break; - case 'o': if (set_config_var(optarg)) flags |= AF_BOGUS; break; - case 'p': push_eval_op('?', optarg); break; - case 'q': if (verbose) verbose--; break; - case 'v': verbose++; break; + case 'c': CMDL; read_config_path(optarg, 0); flags |= AF_SETCONF; break; + case 'e': CMDL; push_eval_op('!', optarg); break; + case 'l': CMDL; push_eval_op('<', optarg); break; + FLAGOPT('n', AF_DRYRUN, { CMDL; }); + case 'o': CMDL; if (set_config_var(optarg)) flags |= AF_BOGUS; break; + case 'p': CMDL; push_eval_op('?', optarg); break; + case 'q': CMDL; if (verbose) verbose--; break; + case 'v': CMDL; verbose++; break; default: flags |= AF_BOGUS; break; } } @@ -565,6 +584,9 @@ int main(int argc, char *argv[]) if (!(flags&AF_VANILLA) && config_find_var(&config, lisp->sect, CF_INHERIT, "image-file")) { var = config_find_var(&config, lisp->sect, CF_INHERIT, "image-path"); + if (!var) + lose("variable `image-path' not defined for Lisp `%s'", + LISPSYS_NAME(lisp)); dstr_reset(&d); config_subst_var(&config, lisp->sect, var, &d); if (file_exists_p(d.p, verbose >= 2 ? FEF_VERBOSE : 0)) config_set_var(&config, lisp->sect, CF_LITERAL, "@image", "t");