From c3cbfcc4d06ea2719ee6562f2c501076dcedb6b9 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Wed, 1 Dec 2010 05:38:16 +0000 Subject: * lisp/core.lisp.in (processCommandLine): Don't export. Rewrite to pull out command line options wherever they are except the ones after "--". (topLevel): Bind *PACKAGE*; don't set it. --- src/ChangeLog | 7 +++++++ src/lisp/core.lisp.in | 49 +++++++++++++++++++++++++++++++------------------ 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index c208ab00..5864c9cb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2010-11-30 Gabriel Dos Reis + + * lisp/core.lisp.in (processCommandLine): Don't export. + Rewrite to pull out command line options wherever they are + except the ones after "--". + (topLevel): Bind *PACKAGE*; don't set it. + 2010-11-30 Gabriel Dos Reis * driver/utils.cc: Commonalize some of option handling code. diff --git a/src/lisp/core.lisp.in b/src/lisp/core.lisp.in index 89debd5e..d7a3268b 100644 --- a/src/lisp/core.lisp.in +++ b/src/lisp/core.lisp.in @@ -94,7 +94,6 @@ "getOptionValue" "getCommandLineArguments" - "processCommandLine" "handleCommandLine" "$originalLispTopLevel" "link" @@ -407,19 +406,34 @@ ;; of the command line into a list. The processing stop as soon as ;; a non-option form is encountered. OPTIONS-SO-FAR accumulates the ;; the list of processed options. -(defun |processCommandLine| (argv options-so-far) - (if (and argv (>= (length (car argv)) 2) - (equal "--" (subseq (car argv) 0 2))) - (let ((option (|parseOption| (car argv)))) - (cond ((symbolp option) - (|processCommandLine| (cdr argv) - (cons (cons option t) options-so-far))) - ((consp option) - (|processCommandLine| (cdr argv) (cons option options-so-far))) - (t (|internalError| - (format nil "processCommandLine: unknown option ~S" - option))))) - (values options-so-far argv))) +(defun |processCommandLine| (argv options-so-far args-so-far) + (cond ((null argv) + ;; no more command-line argument to process + (values options-so-far (nreverse args-so-far))) + ((equal "--" (car argv)) + ;; end of command-line options + (values options-so-far (concatenate 'list + (nreverse args-so-far) + (cdr argv)))) + ((or (< (length (car argv)) 2) + (not (equal "--" (subseq (car argv) 0 2)))) + ;; not a command-line option + (|processCommandLine| (cdr argv) + options-so-far + (cons (car argv) args-so-far))) + (t (let ((option (|parseOption| (car argv)))) + (cond ((symbolp option) + (|processCommandLine| (cdr argv) + (cons (cons option t) + options-so-far) + args-so-far)) + ((consp option) + (|processCommandLine| (cdr argv) + (cons option options-so-far) + args-so-far)) + (t (|internalError| + (format nil "processCommandLine: unknown option ~S" + option)))))))) ;; ;; -*- Building New Lisp Images -*- @@ -718,7 +732,6 @@ ) - ;; ;; -*- --help Handler -*- ;; @@ -872,8 +885,8 @@ ;; The top level entry point to most saved Lisp image. (defun |topLevel|() - (setq *package* (find-package "AxiomCore")) - (let ((command-args (|getCommandLineArguments|))) + (let ((*package* (find-package "AxiomCore")) + (command-args (|getCommandLineArguments|))) (when (null command-args) (|internalError| "empty command line args")) ;; Existing system programming practive, and POSIX, have it @@ -884,7 +897,7 @@ ;; (1) either one of --help or --version, or ;; a filename. (multiple-value-bind - (options args) (|processCommandLine| (cdr command-args) nil) + (options args) (|processCommandLine| (cdr command-args) nil nil) (setq |$sysOpts| options) (setq |$sysArgs| args) -- cgit v1.2.3