X-Git-Url: http://git.kpe.io/?p=kmrcl.git;a=blobdiff_plain;f=strings.lisp;h=3390581840e0d9aafa67b80068ebf05499f93d5d;hp=9a9f42d8a354985df274ac5829ad0118b21e1eea;hb=HEAD;hpb=e54afedd9e96a83521d3eb023e1a22051f387ded diff --git a/strings.lisp b/strings.lisp index 9a9f42d..3390581 100644 --- a/strings.lisp +++ b/strings.lisp @@ -7,8 +7,6 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id$ -;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002-2006 by Kevin M. Rosenberg ;;;; ;;;; KMRCL users are granted the rights to distribute and use this software @@ -720,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)))