;;;; 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
(setq in-word t))
(setq in-word nil)))))
-;; From Larry Hunter with modifications
(defun position-char (char string start max)
(declare (optimize (speed 3) (safety 0) (space 0))
(fixnum start max) (simple-string string))
str)))
+(defun remove-char-string (char str)
+ (declare (character char)
+ (string str))
+ (do* ((len (length str))
+ (out (make-string len))
+ (pos 0 (1+ pos))
+ (opos 0))
+ ((= pos len) (subseq out 0 opos))
+ (declare (fixnum pos opos len)
+ (simple-string out))
+ (let ((c (char str pos)))
+ (declare (character c))
+ (when (char/= c char)
+ (setf (schar out opos) c)
+ (incf opos)))))
+
+
(defun string-strip-ending (str endings)
(if (stringp endings)
(setq endings (list endings)))
(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)))