Changeset 5106
- Timestamp:
- Sep 4, 2006, 4:04:41 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ccl/level-1/l1-reader.lisp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/level-1/l1-reader.lisp
r5050 r5106 25 25 26 26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 27 27 28 28 29 (defparameter *name-char-alist* … … 60 61 ;;;Otherwise, if it consists of two chars, the first of which is ^, 61 62 ;;; return %code-char(c xor 64), where c is the uppercased second char. 62 ;;;Otherwise, if it consists of octal digits, the digits are 63 ;;; interpreted as the (mod 256) ascii code of a character. 63 ;;;Otherwise, if it starts with the prefix "u+" or "U+" followed by 64 ;;; hex digits, the number denoted by those hex digits is interpreted as the 65 ;;; unicode code of the character; if this value is less than 66 ;;; CHAR-CODE-LIMIT, CODE-CHAR of that value is returned. 67 ;;;Otherwise, if it consists of octal digits, the number denoted by 68 ;;; those octal digits is interpreted as per the U+ case above. 64 69 ;;;Otherwise return NIL. 65 70 … … 73 78 (declare (fixnum namelen)) 74 79 (or (cdr (assoc name *name-char-alist* :test #'string-equal)) 75 (if (= namelen 1) 76 (char name 0) 77 (if (and (= namelen 2) (eq (char name 0) #\^)) 78 (code-char (the fixnum (logxor (the fixnum (char-code (char-upcase (char name 1)))) #x40))) 79 (let* ((n 0)) 80 (dotimes (i namelen (code-char (logand n (1- char-code-limit)))) 81 (let* ((code (the fixnum (- (the fixnum (char-code (char name i))) 82 (char-code #\0))))) 83 (declare (fixnum code)) 84 (if (and (>= code 0) 85 (<= code 7)) 86 (setq n (logior code (the fixnum (ash n 3)))) 87 (return)))))))))))) 80 (if (= namelen 1) 81 (char name 0) 82 (if (and (= namelen 2) (eq (char name 0) #\^)) 83 (code-char (the fixnum (logxor (the fixnum (char-code (char-upcase (char name 1)))) #x40))) 84 (let* ((n 0)) 85 (or 86 (if (and (> namelen 2) 87 (or (eql (char name 0) #\U) 88 (eql (char name 0) #\u)) 89 (eql (char name 1) #\+)) 90 (do* ((i 2 (1+ i))) 91 ((= i namelen) (if (< n char-code-limit) 92 (code-char n))) 93 (declare (fixnum i)) 94 (let* ((pos (position (char-upcase (char name i)) 95 "0123456789ABCDEF"))) 96 (if pos 97 (setq n (logior (ash n 4) pos)) 98 (progn 99 (setq n 0) 100 (return)))))) 101 (dotimes (i namelen (code-char (mod n char-code-limit))) 102 (let* ((code (the fixnum (- (the fixnum (char-code (char name i))) 103 (char-code #\0))))) 104 (declare (fixnum code)) 105 (if (and (>= code 0) 106 (<= code 7)) 107 (setq n (logior code (the fixnum (ash n 3)))) 108 (return))))))))))))) 88 109 89 110 (eval-when (:compile-toplevel :load-toplevel :execute) … … 94 115 (set-schar str 3 #\^@) 95 116 (set-schar str 4 #\^J) 96 (set-schar str 5 ( %code-char #xCA))117 (set-schar str 5 (code-char #xa0)) 97 118 str)) 98 119 … … 104 125 (set-schar str 4 #\^@) 105 126 (set-schar str 5 #\^J) 106 (set-schar str 6 ( %code-char #xCA))127 (set-schar str 6 (code-char #xa0)) 107 128 str)) 108 129 ) … … 165 186 ;;; This -really- gets initialized later in the file 166 187 (defvar %initial-readtable% 167 (let* ((ttab (make-array 256 :element-type '( signed-byte 8)))188 (let* ((ttab (make-array 256 :element-type '(unsigned-byte 8))) 168 189 (macs `((#\# . (,#'read-dispatch)))) 169 190 (case :upcase)) … … 187 208 (readtable-arg to) 188 209 (%istruct 'readtable 189 (make-array 256 :element-type '( signed-byte 8))210 (make-array 256 :element-type '(unsigned-byte 8)) 190 211 nil (rdtab.case from)))) 191 212 (setf (rdtab.alist to) (copy-tree (rdtab.alist from))) … … 193 214 (let* ((fttab (rdtab.ttab from)) 194 215 (tttab (rdtab.ttab to))) 195 (dotimes (i 256 to) 196 (setf (uvref tttab i) (uvref fttab i))))) 216 (%copy-ivector-to-ivector fttab 0 tttab 0 257))) 197 217 198 218 (declaim (inline %character-attribute)) … … 200 220 (defun %character-attribute (char attrtab) 201 221 (declare (character char) 202 (type (simple-array ( signed-byte 8) (*)) attrtab)222 (type (simple-array (unsigned-byte 8) (256)) attrtab) 203 223 (optimize (speed 3) (safety 0))) 204 224 (let* ((code (char-code char))) 205 225 (declare (fixnum code)) 206 (aref attrtab code))) 226 (if (< code 256) 227 (aref attrtab code) 228 ;; Should probably have an extension mechanism for things 229 ;; like NBS. 230 $cht_cnst))) 207 231 208 232 ;;; returns: (values attrib <aux-info>), where
Note:
See TracChangeset
for help on using the changeset viewer.
