X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Ftarget-char.lisp;h=ad0f9ee0df697108ee81b981d8a53f08368f94d9;hb=d10b036b1d20e6cff820f72b69af2a06dc362327;hp=3b7eea72585781ee179e08b3ebb1849a1b40cdfb;hpb=c9aeeb418b6ac881bb76f480cace06fb4687d769;p=sbcl.git diff --git a/src/code/target-char.lisp b/src/code/target-char.lisp index 3b7eea7..ad0f9ee 100644 --- a/src/code/target-char.lisp +++ b/src/code/target-char.lisp @@ -68,9 +68,9 @@ while code-point do (setf (gethash code-point names) char-name)) (let ((tree - #!+sb-unicode - (make-huffman-tree - (let (list) + #!+sb-unicode + (make-huffman-tree + (let (list) (maphash (lambda (code name) (declare (ignore code)) (push name list)) @@ -250,8 +250,13 @@ (let ((h-code (cdr (binary-search char-code (car *unicode-character-name-database*) :key #'car)))) - (when h-code - (huffman-decode h-code *unicode-character-name-huffman-tree*)))))) + (cond + (h-code + (huffman-decode h-code *unicode-character-name-huffman-tree*)) + ((< char-code #x10000) + (format nil "U~4,'0X" char-code)) + (t + (format nil "U~8,'0X" char-code))))))) (defun name-char (name) #!+sb-doc @@ -266,12 +271,23 @@ (let ((encoding (huffman-encode (string-upcase name) *unicode-character-name-huffman-tree*))) (when encoding - (let ((char-code - (car (binary-search encoding - (cdr *unicode-character-name-database*) - :key #'cdr)))) - (when char-code - (code-char char-code))))))) + (let* ((char-code + (car (binary-search encoding + (cdr *unicode-character-name-database*) + :key #'cdr))) + (name-string (string name)) + (name-length (length name-string))) + (cond + (char-code + (code-char char-code)) + ((and (or (= name-length 9) + (= name-length 5)) + (char-equal (char name-string 0) #\U) + (loop for i from 1 below name-length + always (digit-char-p (char name-string i) 16))) + (code-char (parse-integer name-string :start 1 :radix 16))) + (t + nil))))))) ;;;; predicates @@ -421,16 +437,21 @@ (ucd-value-1 ,ch) (char-code ,ch))))) +(defun two-arg-char-equal (c1 c2) + (= (equal-char-code c1) (equal-char-code c2))) + (defun char-equal (character &rest more-characters) #!+sb-doc "Return T if all of the arguments are the same character. Font, bits, and case are ignored." (do ((clist more-characters (cdr clist))) ((null clist) t) - (unless (= (equal-char-code (car clist)) - (equal-char-code character)) + (unless (two-arg-char-equal (car clist) character) (return nil)))) +(defun two-arg-char-not-equal (c1 c2) + (/= (equal-char-code c1) (equal-char-code c2))) + (defun char-not-equal (character &rest more-characters) #!+sb-doc "Return T if no two of the arguments are the same character. @@ -440,11 +461,13 @@ ((null list) t) (unless (do* ((l list (cdr l))) ((null l) t) - (if (= (equal-char-code head) - (equal-char-code (car l))) + (if (two-arg-char-equal head (car l)) (return nil))) (return nil)))) +(defun two-arg-char-lessp (c1 c2) + (< (equal-char-code c1) (equal-char-code c2))) + (defun char-lessp (character &rest more-characters) #!+sb-doc "Return T if the arguments are in strictly increasing alphabetic order. @@ -452,10 +475,12 @@ (do* ((c character (car list)) (list more-characters (cdr list))) ((null list) t) - (unless (< (equal-char-code c) - (equal-char-code (car list))) + (unless (two-arg-char-lessp c (car list)) (return nil)))) +(defun two-arg-char-greaterp (c1 c2) + (> (equal-char-code c1) (equal-char-code c2))) + (defun char-greaterp (character &rest more-characters) #!+sb-doc "Return T if the arguments are in strictly decreasing alphabetic order. @@ -463,10 +488,12 @@ (do* ((c character (car list)) (list more-characters (cdr list))) ((null list) t) - (unless (> (equal-char-code c) - (equal-char-code (car list))) + (unless (two-arg-char-greaterp c (car list)) (return nil)))) +(defun two-arg-char-not-greaterp (c1 c2) + (<= (equal-char-code c1) (equal-char-code c2))) + (defun char-not-greaterp (character &rest more-characters) #!+sb-doc "Return T if the arguments are in strictly non-decreasing alphabetic order. @@ -474,10 +501,12 @@ (do* ((c character (car list)) (list more-characters (cdr list))) ((null list) t) - (unless (<= (equal-char-code c) - (equal-char-code (car list))) + (unless (two-arg-char-not-greaterp c (car list)) (return nil)))) +(defun two-arg-char-not-lessp (c1 c2) + (>= (equal-char-code c1) (equal-char-code c2))) + (defun char-not-lessp (character &rest more-characters) #!+sb-doc "Return T if the arguments are in strictly non-increasing alphabetic order. @@ -485,8 +514,7 @@ (do* ((c character (car list)) (list more-characters (cdr list))) ((null list) t) - (unless (>= (equal-char-code c) - (equal-char-code (car list))) + (unless (two-arg-char-not-lessp c (car list)) (return nil)))) ;;;; miscellaneous functions