Changeset 5260


Ignore:
Timestamp:
Sep 24, 2006, 7:14:05 PM (18 years ago)
Author:
Gary Byers
Message:

Check for assumptions about character size.
Remove some %i-isms (fixnum arithmetic), make assertions about type
of char-code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/lib/chars.lisp

    r5251 r5260  
    6868
    6969
    70 ;True for ascii codes 13 and 32-126 inclusive.
     70;True for ascii codes 10 and 32-126 inclusive.
    7171(defun standard-char-p (c)
    7272  "The argument must be a character object. STANDARD-CHAR-P returns T if the
     
    8282
    8383
    84 ; if no table - then what?
    8584(defun upper-case-p (c)
    8685  "The argument must be a character object; UPPER-CASE-P returns T if the
    8786   argument is an upper-case character, NIL otherwise."
    8887  (let* ((code (char-code c)))
    89     (declare (optimize (speed 3)(safety 0)))
    90     (and (%i>= code (char-code #\A))
    91          (%i<= code (char-code #\Z)))))
    92 
    93 
    94 
    95 
    96 ; I assume nobody cares that this be blindingly fast
     88    (declare (type (mod #x110000) code))
     89    (and (>= code (char-code #\A))
     90         (<= code (char-code #\Z)))))
     91
     92
     93
     94
    9795(defun both-case-p (c)
    9896  "The argument must be a character object. BOTH-CASE-P returns T if the
     
    10098  both upper and lower case. For ASCII, this is the same as ALPHA-CHAR-P."
    10199  (let* ((code (char-code c)))
    102     (declare (optimize (speed 3)(safety 0)))
    103     (if (%i>= code (char-code #\A))
    104       (if (%i<= code (char-code #\Z))
    105         t
    106         (if (%i>= code (char-code #\a))
    107           (%i<= code (char-code #\z)))))))
     100    (declare (type (mod #x110000) code))
     101    (or (and (>= code (char-code #\A))
     102             (<= code (char-code #\Z)))
     103        (and (>= code (char-code #\a))
     104             (<= code (char-code #\z))))))
    108105 
    109106(defun alphanumericp (c)
     
    111108   argument is either numeric or alphabetic."
    112109  (let ((code (char-code c)))
    113     (declare (fixnum code))
     110    (declare (type (mod #x110000) code))
    114111    (or
    115112     (and (>= code (char-code #\0))
     
    156153          (return))))))
    157154
    158 ; Compares each char against all following chars, not just next one. Tries
    159 ; to be fast for one or two args.
     155;;; Compares each char against all following chars, not just next one. Tries
     156;;; to be fast for one or two args.
    160157(defun char-not-equal (char &rest others)
    161158  "Return T if no two of the arguments are the same character.
     
    165162    (let* ((rest (cdr others)))
    166163      (cond
    167        (rest                       ; more than 2 args, no table
     164       (rest                   
    168165        (setq char (char-code (char-upcase char)))
    169166        (do ((list others (cdr list)))
Note: See TracChangeset for help on using the changeset viewer.