mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-06 02:30:42 -08:00
Better handling of parsing integer and float values
This commit is contained in:
parent
f631a43059
commit
d07b41dd73
10 changed files with 155 additions and 132 deletions
|
|
@ -135,6 +135,38 @@ CLOG-OBJ unless :NAME is set and is used instead."))
|
|||
"on"
|
||||
"off"))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;
|
||||
;; js-to-integer ;;
|
||||
;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defun js-to-integer (value &key (default 0))
|
||||
"Returns two values first as an integer and second the original value"
|
||||
(cond ((typep value 'integer)
|
||||
(values value value))
|
||||
((typep value 'string)
|
||||
(let ((r (parse-integer value :junk-allowed t)))
|
||||
(if r
|
||||
(values r value)
|
||||
(values default value))))
|
||||
(t
|
||||
(values default value))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;
|
||||
;; js-to-float ;;
|
||||
;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defun js-to-float (value &key (default 0.0d0))
|
||||
"Returns two values first as a float and second the original value"
|
||||
(cond ((typep value 'float)
|
||||
(values value value))
|
||||
((typep value 'string)
|
||||
(let ((r (parse-float value :type 'double-float :junk-allowed t)))
|
||||
(if r
|
||||
(values r value)
|
||||
(values default value))))
|
||||
(t
|
||||
(values default value))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;
|
||||
;; escape-string ;;
|
||||
;;;;;;;;;;;;;;;;;;;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue