Raymond Toy pushed to branch issue-326-char-casing-cleanup at cmucl / cmucl
Commits:
-
b8887cd6
by Raymond Toy at 2024-06-03T14:38:08-07:00
-
e4a3d3b5
by Raymond Toy at 2024-06-03T15:59:09-07:00
-
c3e7e0b4
by Raymond Toy at 2024-06-03T16:11:47-07:00
-
7c711f4f
by Raymond Toy at 2024-06-03T16:12:48-07:00
3 changed files:
Changes:
... | ... | @@ -418,14 +418,14 @@ |
418 | 418 | |
419 | 419 | (defmacro equal-char-code (character)
|
420 | 420 | `(let ((ch (char-code ,character)))
|
421 | - ;; Handle ASCII separately for bootstrapping and for unidata missing.
|
|
422 | - (if (< (char-code #\@) ch (char-code #\[))
|
|
423 | - (+ ch 32)
|
|
424 | - #-(and unicode (not unicode-bootstrap))
|
|
425 | - ch
|
|
426 | - #+(and unicode (not unicode-bootstrap))
|
|
427 | - (if (> ch +ascii-limit+) (unicode-lower ch) ch))))
|
|
428 | - |
|
421 | + ;; Handle ASCII separately for bootstrapping.
|
|
422 | + (cond ((<= (char-code #\A) ch (char-code #\Z))
|
|
423 | + (logxor ch #x20))
|
|
424 | + #+(and unicode (not unicode-bootstrap))
|
|
425 | + ((> ch +ascii-limit+)
|
|
426 | + (case-mapping-lower-case ch))
|
|
427 | + (t
|
|
428 | + ch))))
|
|
429 | 429 | |
430 | 430 | (defun char-equal (character &rest more-characters)
|
431 | 431 | "Returns T if all of its arguments are the same character.
|
... | ... | @@ -3343,7 +3343,7 @@ |
3343 | 3343 | x)
|
3344 | 3344 | #+(and unicode (not unicode-bootstrap))
|
3345 | 3345 | '(let ((m (char-code x)))
|
3346 | - (cond ((< (char-code #\a) m (char-code #\{))
|
|
3346 | + (cond ((< (char-code #\`) m (char-code #\{))
|
|
3347 | 3347 | (code-char (logxor m #x20)))
|
3348 | 3348 | ((> m lisp::+ascii-limit+)
|
3349 | 3349 | (code-char (lisp::case-mapping-upper-case m)))
|
1 | +;; Tests of char functions
|
|
2 | + |
|
3 | +(defpackage :char-tests
|
|
4 | + (:use :cl :lisp-unit))
|
|
5 | + |
|
6 | +(in-package "CHAR-TESTS")
|
|
7 | + |
|
8 | +(define-test char-equal
|
|
9 | + (:tag :issues)
|
|
10 | + (let ((test-codes
|
|
11 | + ;; Find all the codes where the CL lower case character
|
|
12 | + ;; doesn't match the Unicode lower case character.
|
|
13 | + (loop for code from 128 below char-code-limit
|
|
14 | + for ch = (code-char code)
|
|
15 | + when (/= (char-code (char-downcase ch)) (or (lisp::unicode-lower code) code))
|
|
16 | + collect code)))
|
|
17 | + (dolist (code test-codes)
|
|
18 | + ;; Verify that we convert to the CL lower case character instead
|
|
19 | + ;; of the Unicode lower case character for the cases where these
|
|
20 | + ;; are different.
|
|
21 | + (assert-false (char-equal (code-char (lisp::unicode-lower code))
|
|
22 | + (code-char code))
|
|
23 | + code
|
|
24 | + (lisp::unicode-lower code))))) |