Changeset 8898


Ignore:
Timestamp:
Mar 26, 2008, 4:13:45 PM (11 years ago)
Author:
gb
Message:

Fix several issues in PARSE-INTEGER (type-/bounds-/sanity-checking.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/lib/read.lisp

    r8421 r8898  
    140140         (apply sd (nreverse args))))))
    141141
    142 ;from slisp reader2.lisp.
     142;;;from slisp reader2.lisp, and apparently not touched in 20 years.
    143143(defun parse-integer (string &key (start 0) end
    144144                      (radix 10) junk-allowed)
     
    149149  (flet ((parse-integer-not-integer-string (s)
    150150           (error 'parse-integer-not-integer-string :string s)))
    151     (declare (inline not-integer-string-error))
    152     (when (null end)
    153       (setq end (length string)))
     151    (declare (inline parse-integer-not-integer-string))
     152
     153    (unless (typep string 'string)
     154      (setq string (require-type string 'string)))
     155    (setq end (check-sequence-bounds string start end))
     156    (setq radix (%validate-radix radix))
    154157    (let ((index (do ((i start (1+ i)))
    155158                     ((= i end)
     
    162165        (result 0))
    163166       (let ((char (char string index)))
    164             (cond ((char= char #\-)
     167            (cond ((eql char #\-)
    165168                   (setq minusp t)
    166169                   (setq index (1+ index)))
    167                   ((char= char #\+)
     170                  ((eql char #\+)
    168171                    (setq index (1+ index))
    169172                   )))
Note: See TracChangeset for help on using the changeset viewer.