From a09fa1e3605d190ccc02f2254abacb1eb4df150e Mon Sep 17 00:00:00 2001 From: dos-reis Date: Sun, 14 Sep 2008 03:40:49 +0000 Subject: * lisp/core.lisp.in (TRANSLATE-OPTION-VALUE): New. (parseOption): Use it. --- src/ChangeLog | 5 +++++ src/lisp/core.lisp.in | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index e3adaa73..4468c566 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-09-13 Gabriel Dos Reis + + * lisp/core.lisp.in (TRANSLATE-OPTION-VALUE): New. + (parseOption): Use it. + 2008-09-13 Gabriel Dos Reis * lisp/core.lisp.in (|$NativeTypeTable|): Don' include `pointer' diff --git a/src/lisp/core.lisp.in b/src/lisp/core.lisp.in index 7b9d5710..d19e1e5a 100644 --- a/src/lisp/core.lisp.in +++ b/src/lisp/core.lisp.in @@ -316,6 +316,21 @@ (defun |Option| (opt) (intern (string opt) (find-package "AxiomCore"))) + +;; Translate option value: +;; "no" -> nil +;; "yes" -> t +;; [0-9]+ -> integer value +;; otherwise -> input string unmolested +(defun translate-option-value (val) + (cond ((string= val "no") nil) + ((string= val "yes") t) + (t (multiple-value-bind (ival idx) + (parse-integer val :junk-allowed t) + (cond ((null ival) val) + ((eql idx (length val)) ival) + (t val)))))) + ;; Returns a pair (name . value) if OPTION if of the form "--name=value", ;; where name is a symbol and value is a string. Otherwise, if ;; OPTION is of the form "--name", returns the symbol name. @@ -323,7 +338,8 @@ (setq option (subseq option 2)) (let ((p (position #\= option))) (if p - (cons (|Option| (subseq option 0 p)) (subseq option (1+ p))) + (cons (|Option| (subseq option 0 p)) + (translate-option-value (subseq option (1+ p)))) (|Option| option)))) ;; Returns the value specified for OPTION. Otherwise, return nil -- cgit v1.2.3