aboutsummaryrefslogtreecommitdiff
path: root/src/lisp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2010-12-01 08:09:08 +0000
committerdos-reis <gdr@axiomatics.org>2010-12-01 08:09:08 +0000
commit5a73a0e19044f6dc949b7633f5f64867a019cfdd (patch)
treebfb7a6c50d9acfaaf36a334504fe636ce921348b /src/lisp
parentc3cbfcc4d06ea2719ee6562f2c501076dcedb6b9 (diff)
downloadopen-axiom-5a73a0e19044f6dc949b7633f5f64867a019cfdd.tar.gz
* lisp/core.lisp.in (handleCommandLine): Don't export. Rewrite.
(RUN-DRIVER): Split from handleCommandLine.
Diffstat (limited to 'src/lisp')
-rw-r--r--src/lisp/core.lisp.in74
1 files changed, 38 insertions, 36 deletions
diff --git a/src/lisp/core.lisp.in b/src/lisp/core.lisp.in
index d7a3268b..7f7e6357 100644
--- a/src/lisp/core.lisp.in
+++ b/src/lisp/core.lisp.in
@@ -94,7 +94,6 @@
"getOptionValue"
"getCommandLineArguments"
- "handleCommandLine"
"$originalLispTopLevel"
"link"
"installDriver"
@@ -694,43 +693,45 @@
(funcall driver prog-name options args)))
(defun |hasHandler?| (request)
- (|getDriver| request))
+ (or (|getDriver| request)
+ (|useFileType?| request)))
+
+(defun run-driver (prog-name action options args)
+ (cond ((|useFileType?| (car action))
+ ;; If the action is file-type dependent, make sure
+ ;; we have at least one file.
+ (unless (not (null args))
+ (|coreError| "missing input files"))
+ (dolist (f args t)
+ (let* ((name (car action))
+ (file-type (or (|getFileType| f)
+ (|useFileType?| name)))
+ (request (cons name file-type)))
+ (unless (|handleRequest| prog-name request options f)
+ (return nil)))))
+ (t (|handleRequest| prog-name (car action) options args))))
+
(defun |handleCommandLine| (prog-name options args)
(when (or options args)
- (dolist (opt options nil)
- (cond ((eq (car opt) (|Option| "help")) ; print help, get out of here
- (|helpHandler| prog-name))
-
- ;; If we need to do an action based on the extension of
- ;; input file, make sure we have at least one.
- ((|useFileType?| (car opt))
- (unless args
- (|coreError| "missing input files")
- (return t))
- (dolist (f args)
- (let* ((opt-name (car opt))
- (file-type (or (|getFileType| f)
- (|useFileType?| opt-name)))
- (request (cons opt-name file-type)))
- (unless (|handleRequest| prog-name request options f)
- (return nil))))
- (return t))
-
- ;; In general, nothing is to be done for option value
- ;; specification. However, some specifications may require
- ;; some special handlers.
- ((stringp (cdr opt))
- (when (|hasHandler?| (car opt))
- (unless (|handleRequest| prog-name (car opt) options args)
- (return nil))))
-
- ;; By now, we are assumed to execute a driver associated
- ;; with the option. Hope one is installed...
- (t (unless (|handleRequest| prog-name (car opt) options args)
- (return nil))))))
-
-)
+ (let (action)
+ (dolist (opt options)
+ (cond ((stringp (cdr opt))
+ ;; In general, nothing is to be done for option value
+ ;; specifications, except when they require special handlers.
+ (when (|hasHandler?| (car opt))
+ (unless (|handleRequest| prog-name (car opt) options args)
+ (return nil))))
+
+ ;; Don't allow for more than one driver request.
+ ((|hasHandler?| (car opt))
+ (if (not (null action))
+ (|coreError| "multiple driver request")
+ (setq action opt)))))
+ ;; By now, we hope to have figured out what action to perform.
+ (cond ((consp action)
+ (run-driver prog-name action options args))
+ (t nil)))))
;;
;; -*- --help Handler -*-
@@ -750,7 +751,8 @@
(write-line " --load-directory=<dir> use <dir> as search path for modules")
(write-line " --make create an executable"))
-(defun |helpHandler|(prog-name)
+(defun |helpHandler|(prog-name options args)
+ (declare (ignore options args))
(|printUsage| prog-name)
(|coreQuit|))