X-Git-Url: https://git.distorted.org.uk/~mdw/runlisp/blobdiff_plain/6c39ec6d05467457c590ec93ad98c179be6618af..c23fb2403e6f0f2ec200f317931d09e992064802:/runlisp.c diff --git a/runlisp.c b/runlisp.c index 65741ad..2573b82 100644 --- a/runlisp.c +++ b/runlisp.c @@ -199,9 +199,10 @@ static void usage(FILE *fp) fprintf(fp, "\ usage:\n\ %s [OPTIONS] [--] SCRIPT [ARGUMENTS ...]\n\ - %s [OPTIONS] [-e EXPR] [-p EXPR] [-l FILE] [--] [ARGUMENTS ...]\n\ + %s [OPTIONS] [-e EXPR] [-d EXPR] [-p EXPR] [-l FILE]\n\ + [--] [ARGUMENTS ...]\n\ OPTIONS:\n\ - [-CDEnqv] [+DEn] [-L SYS,SYS,...] [-c CONF] [-o [SECT:]VAR=VAL]\n", + [-DEnqv] [+DEn] [-L SYS,SYS,...] [-c CONF] [-o [SECT:]VAR=VAL]\n", progname, progname); } @@ -228,9 +229,10 @@ Lisp implementation selection:\n\ -L, --accept-lisp=SYS,SYS,... Only use the listed Lisp systems.\n\ \n\ Evaluation mode:\n\ + -d, --dump-expression=EXPR Print (`prin1') EXPR (repeatable).\n\ -e, --evaluate-expression=EXPR Evaluate EXPR for effect (repeatable).\n\ -l, --load-file=FILE Load FILE (repeatable).\n\ - -p, --print-expression=EXPR Print (`prin1') EXPR (repeatable).\n", + -p, --print-expression=EXPR Print (`princ') EXPR (repeatable).\n", fp); } @@ -257,6 +259,7 @@ static void parse_options(int argc, char *argv[]) { "command-line-only", OPTF_NEGATE, 0, 'E' }, { "accept-lisp", OPTF_ARGREQ, 0, 'L' }, { "config-file", OPTF_ARGREQ, 0, 'c' }, + { "dump-expression", OPTF_ARGREQ, 0, 'd' }, { "evaluate-expression", OPTF_ARGREQ, 0, 'e' }, { "load-file", OPTF_ARGREQ, 0, 'l' }, { "dry-run", OPTF_NEGATE, 0, 'n' }, @@ -280,7 +283,7 @@ static void parse_options(int argc, char *argv[]) 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, + i = mdwopt(argc, argv, "+hVD+E+L:c:d:e:l:n+o:p:qv", opts, 0, 0, OPTF_NEGATION | OPTF_NOPROGNAME); if (i < 0) break; switch (i) { @@ -293,16 +296,20 @@ static void parse_options(int argc, char *argv[]) offsetof(struct lispsys, next_accept)); break; case 'c': CMDL; read_config_path(optarg, 0); flags |= AF_SETCONF; break; + case 'd': CMDL; push_eval_op('?', optarg); 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 'p': CMDL; push_eval_op('=', optarg); break; case 'q': CMDL; if (verbose) verbose--; break; case 'v': CMDL; verbose++; break; default: flags |= AF_BOGUS; break; } } + +#undef FLAGOPT +#undef CMDL } /* Extract and process the embedded options from a SCRIPT. */ @@ -536,8 +543,7 @@ int main(int argc, char *argv[]) } *tail = 0; lisps.tail = tail; - /* Make sure that the acceptable and preferred Lisps actually exist. */ - check_lisps("acceptable", &accept, offsetof(struct lispsys, next_accept)); + /* Make sure that the preferred Lisps actually exist. */ check_lisps("preferred", &prefer, offsetof(struct lispsys, next_prefer)); /* If there are no acceptable Lisps, then we'll take all of them. */ @@ -552,13 +558,14 @@ int main(int argc, char *argv[]) /* Build the final list of Lisp systems in the order in which we'll try * them: first, preferred Lisps which are acceptable, and then acceptable - * Lisps which aren't preferred. + * Lisps which are known but not preferred. */ tail = &order.head; for (lisp = prefer.head; lisp; lisp = lisp->next_prefer) if (lisp->f&LF_ACCEPT) { *tail = lisp; tail = &lisp->next_order; } for (lisp = accept.head; lisp; lisp = lisp->next_accept) - if (!(lisp->f&LF_PREFER)) { *tail = lisp; tail = &lisp->next_order; } + if ((lisp->f&LF_KNOWN) && !(lisp->f&LF_PREFER)) + { *tail = lisp; tail = &lisp->next_order; } *tail = 0; /* Maybe dump out the various lists of Lisp systems we've collected. */