Skip to content
Snippets Groups Projects
Commit b6cdc8cf authored by wlott's avatar wlott
Browse files

Fixed bogus fixnum declaration in parse-integer.

parent de841ba5
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
;;; Scott Fahlman (FAHLMAN@CMUC). ;;; Scott Fahlman (FAHLMAN@CMUC).
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
;;; $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/reader.lisp,v 1.3 1990/08/24 18:12:38 wlott Exp $ ;;; $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/reader.lisp,v 1.4 1990/09/06 19:38:45 wlott Exp $
;;; ;;;
;;; Spice Lisp Reader ;;; Spice Lisp Reader
;;; Written by David Dill ;;; Written by David Dill
...@@ -1229,25 +1229,23 @@ ...@@ -1229,25 +1229,23 @@
;;;; PARSE-INTEGER. ;;;; PARSE-INTEGER.
(defun parse-integer (string &key (start 0) (end (length string)) (defun parse-integer (string &key (start 0) end (radix 10) junk-allowed)
(radix 10) junk-allowed)
"Examine the substring of string delimited by start and end "Examine the substring of string delimited by start and end
(default to the beginning and end of the string) It skips over (default to the beginning and end of the string) It skips over
whitespace characters and then tries to parse an integer. The whitespace characters and then tries to parse an integer. The
radix parameter must be between 2 and 36." radix parameter must be between 2 and 36."
(declare (fixnum end)) (let* ((end (or end (length string)))
(if (null end) (setq end (length string))) (index (do ((i start (1+ i)))
(let ((index (do ((i start (1+ i))) ((= i end)
((= i end) (if junk-allowed
(if junk-allowed (return-from parse-integer (values nil end))
(return-from parse-integer (values nil end)) (error "No non-whitespace characters in number.")))
(error "No non-whitespace characters in number."))) (declare (fixnum i))
(declare (fixnum i)) (unless (whitespacep (char string i)) (return i))))
(unless (whitespacep (char string i)) (return i)))) (minusp nil)
(minusp nil) (found-digit nil)
(found-digit nil) (result 0))
(result 0)) (declare (fixnum end index))
(declare (fixnum index))
(let ((char (char string index))) (let ((char (char string index)))
(cond ((char= char #\-) (cond ((char= char #\-)
(setq minusp t) (setq minusp t)
...@@ -1255,23 +1253,23 @@ ...@@ -1255,23 +1253,23 @@
((char= char #\+) ((char= char #\+)
(incf index)))) (incf index))))
(loop (loop
(when (= index end) (return nil)) (when (= index end) (return nil))
(let* ((char (char string index)) (let* ((char (char string index))
(weight (digit-char-p char radix))) (weight (digit-char-p char radix)))
(cond (weight (cond (weight
(setq result (+ weight (* result radix)) (setq result (+ weight (* result radix))
found-digit t)) found-digit t))
(junk-allowed (return nil)) (junk-allowed (return nil))
((whitespacep char) ((whitespacep char)
(do ((jndex (1+ index) (1+ jndex))) (do ((jndex (1+ index) (1+ jndex)))
((= jndex end)) ((= jndex end))
(declare (fixnum jndex)) (declare (fixnum jndex))
(unless (whitespacep (char string jndex)) (unless (whitespacep (char string jndex))
(error "There's junk in this string: ~S." string))) (error "There's junk in this string: ~S." string)))
(return nil)) (return nil))
(t (t
(error "There's junk in this string: ~S." string)))) (error "There's junk in this string: ~S." string))))
(incf index)) (incf index))
(values (values
(if found-digit (if found-digit
(if minusp (- result) result) (if minusp (- result) result)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment