X-Git-Url: http://git.kpe.io/?p=kmrcl.git;a=blobdiff_plain;f=strings.lisp;fp=strings.lisp;h=3390581840e0d9aafa67b80068ebf05499f93d5d;hp=4dcda494249b45e44b6166bf304f0c154f0ce8a2;hb=43e5015c6779edaa3894592b8a166f15cd163fa3;hpb=f2d2f950bfc1645a591883b215b896109c79ee13 diff --git a/strings.lisp b/strings.lisp index 4dcda49..3390581 100644 --- a/strings.lisp +++ b/strings.lisp @@ -718,3 +718,14 @@ for characters in a string" (do ((x (read stream nil eof) (read stream nil eof)) (l nil (cons x l))) ((eq x eof) (nreverse l)))))) + +(defun safely-read-from-string (str &rest read-from-string-args) + "Read an expression from the string STR, with *READ-EVAL* set +to NIL. Any unsafe expressions will be replaced by NIL in the +resulting S-Expression." + (let ((*read-eval* nil)) + (ignore-errors (apply 'read-from-string str read-from-string-args)))) + +(defun parse-float (f) + (let ((*read-default-float-format* 'double-float)) + (coerce (safely-read-from-string f) 'double-float)))