Changeset 12304


Ignore:
Timestamp:
Jun 25, 2009, 6:45:35 PM (10 years ago)
Author:
gz
Message:

r12259 from trunk

File:
1 edited

Legend:

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

    r12048 r12304  
    5656
    5757
    58 
    59 ;True for ascii codes 32-126 inclusive.
    60 ; and for guys >= 128. Its really a function of the font of the moment.
     58(declaim (inline %control-char-p))
     59
     60(defun %control-char-p (char)
     61  (let* ((code (char-code char)))
     62    (declare (type (mod #x110000) code))
     63    ;; If we believe that "most" characters will have relatively
     64    ;; small codes, then doing a linear search on this short
     65    ;; list is probably faster than binary search on a vector
     66    ;; or other approaches.
     67    (dolist (pair '((0 . #x1f)                          ;c0
     68                    (#x7f . #x9f)                       ;#\rubout, c1
     69                    (#x34f . #x34f)                     ;combining grapheme joiner.
     70                    (#x200c . #x200f)
     71                    (#x202a . #x202e)
     72                    (#x2060 . #x2063)
     73                    (#x206a . #x206f)
     74                    #+darwin-target
     75                    (#xf700 . #xf7ff)
     76                    (#xfe00 . #xfe0f)
     77                    (#xfeff . #xfeff)                   ;byte-order mark (0-width space).
     78                    (#xfff0 . #xfffd)
     79                   
     80                    (#xe0000 . #xefffd)))
     81      (let* ((low (car pair))
     82             (high (cdr pair)))
     83        (declare (type (mod #x110000) low high))
     84        (if (> low code)
     85          (return nil)
     86          (if (<= code high)
     87            (return t)))))))
     88
     89
     90
     91;;; Characters that aren't control/formatting characters are graphic.
    6192(defun graphic-char-p (c)
    62   "The argument must be a character object. GRAPHIC-CHAR-P returns T if the
    63   argument is a printing character (space through ~ in ASCII), otherwise
    64   returns NIL."
    65   (let* ((code (char-code c)))
    66     (unless (eq c #\rubout)
    67       (>= code (char-code #\space)))))
     93  "The argument must be a character object. GRAPHIC-CHAR-P returns NIL if the
     94  argument is a Unicode control character, otherwise returns T."
     95  (not (%control-char-p c)))
    6896
    6997
Note: See TracChangeset for help on using the changeset viewer.