aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2008-09-14 03:40:49 +0000
committerdos-reis <gdr@axiomatics.org>2008-09-14 03:40:49 +0000
commita09fa1e3605d190ccc02f2254abacb1eb4df150e (patch)
tree17b9b0f7af098c4a9fb88e077f0e9b884b9f67c8
parent6feba77e44809a9eb39f9cc54bfa7c01f42eb098 (diff)
downloadopen-axiom-a09fa1e3605d190ccc02f2254abacb1eb4df150e.tar.gz
* lisp/core.lisp.in (TRANSLATE-OPTION-VALUE): New.
(parseOption): Use it.
-rw-r--r--src/ChangeLog5
-rw-r--r--src/lisp/core.lisp.in18
2 files changed, 22 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e3adaa73..4468c566 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
2008-09-13 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * lisp/core.lisp.in (TRANSLATE-OPTION-VALUE): New.
+ (parseOption): Use it.
+
+2008-09-13 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* lisp/core.lisp.in (|$NativeTypeTable|): Don' include `pointer'
and `buffer'.
* lisp/Makefile.in (pointer_type): Remove.
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