X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=ecmalisp.lisp;h=cd93750ab8dad28633d77133f61c184bf6e615cf;hb=9ed43a93fd7f52e7e229ff356fcc164ef66a23e8;hp=fbbdbb1f028a7a20a609d0d85e0682c63f7bcc39;hpb=775baf9e8712e5711303e49367c72d39fb1f7f79;p=jscl.git diff --git a/ecmalisp.lisp b/ecmalisp.lisp index fbbdbb1..cd93750 100644 --- a/ecmalisp.lisp +++ b/ecmalisp.lisp @@ -1132,31 +1132,34 @@ (defun !parse-integer (string junk-allow) (block nil (let ((value 0) - (index 0) - (size (length string)) - (sign 1)) + (index 0) + (size (length string)) + (sign 1)) (when (zerop size) (return (values nil 0))) ;; Optional sign (case (char string 0) - (#\+ (incf index)) - (#\- (setq sign -1) - (incf index))) + (#\+ (incf index)) + (#\- (setq sign -1) + (incf index))) ;; First digit (unless (and (< index size) - (setq value (digit-char-p (char string index)))) - (return (values nil index))) + (setq value (digit-char-p (char string index)))) + (return (values nil index))) (incf index) ;; Other digits (while (< index size) - (let ((digit (digit-char-p (char string index)))) - (unless digit (return)) - (setq value (+ (* value 10) digit)) - (incf index))) + (let ((digit (digit-char-p (char string index)))) + (unless digit (return)) + (setq value (+ (* value 10) digit)) + (incf index))) + ;; Trailing whitespace + (do ((i index (1+ i))) + ((or (= i size) (not (whitespacep (char string i)))) + (and (= i size) (setq index i)))) (if (or junk-allow - (= index size) - (char= (char string index) #\space)) - (values (* sign value) index) - (values nil index))))) + (= index size)) + (values (* sign value) index) + (values nil index))))) #+ecmalisp (defun parse-integer (string)