Raymond Toy pushed to branch issue-316-support-roundtrip-char-casing at cmucl / cmucl
Commits:
-
95e6ffdd
by Raymond Toy at 2024-05-16T14:04:14-07:00
-
f3dac007
by Raymond Toy at 2024-05-16T14:05:53-07:00
2 changed files:
Changes:
... | ... | @@ -463,18 +463,7 @@ |
463 | 463 | (defun char-upcase (char)
|
464 | 464 | "Returns CHAR converted to upper-case if that is possible."
|
465 | 465 | (declare (character char))
|
466 | - #-(and unicode (not unicode-bootstrap))
|
|
467 | - (if (lower-case-p char)
|
|
468 | - (code-char (- (char-code char) 32))
|
|
469 | - char)
|
|
470 | - #+(and unicode (not unicode-bootstrap))
|
|
471 | - (let ((m (char-code char)))
|
|
472 | - (cond ((< 96 m 123) (code-char (- m 32)))
|
|
473 | - ((> m +unicode-lower-limit+)
|
|
474 | - (if (member (unicode-category m) '(92 32 75 109))
|
|
475 | - char
|
|
476 | - (code-char (unicode-upper m))))
|
|
477 | - (t char))))
|
|
466 | + (char-upcase char))
|
|
478 | 467 | |
479 | 468 | (defun char-titlecase (char)
|
480 | 469 | "Returns CHAR converted to title-case if that is possible."
|
... | ... | @@ -492,18 +481,7 @@ |
492 | 481 | (defun char-downcase (char)
|
493 | 482 | "Returns CHAR converted to lower-case if that is possible."
|
494 | 483 | (declare (character char))
|
495 | - #-(and unicode (not unicode-bootstrap))
|
|
496 | - (if (upper-case-p char)
|
|
497 | - (code-char (+ (char-code char) 32))
|
|
498 | - char)
|
|
499 | - #+(and unicode (not unicode-bootstrap))
|
|
500 | - (let ((m (char-code char)))
|
|
501 | - (cond ((> m +unicode-lower-limit+)
|
|
502 | - (if (member (unicode-category m) '(92 75 109))
|
|
503 | - char
|
|
504 | - (code-char (unicode-lower m))))
|
|
505 | - ((< 64 m 91) (code-char (+ m 32)))
|
|
506 | - (t char))))
|
|
484 | + (char-downcase char))
|
|
507 | 485 | |
508 | 486 | (defun digit-char (weight &optional (radix 10))
|
509 | 487 | "All arguments must be integers. Returns a character object that
|
... | ... | @@ -3335,9 +3335,8 @@ |
3335 | 3335 | (= (lisp::equal-char-code a)
|
3336 | 3336 | (lisp::equal-char-code b)))))
|
3337 | 3337 | |
3338 | -(deftransform char-upcase ((x) (base-char))
|
|
3338 | +(deftransform char-upcase ((x) (character))
|
|
3339 | 3339 | "open code"
|
3340 | - ;; NOTE: This MUST match what the function char-upcase does.
|
|
3341 | 3340 | #-(and unicode (not unicode-bootstrap))
|
3342 | 3341 | '(if (lower-case-p x)
|
3343 | 3342 | (code-char (- (char-code x) 32))
|
... | ... | @@ -3345,25 +3344,22 @@ |
3345 | 3344 | #+(and unicode (not unicode-bootstrap))
|
3346 | 3345 | '(let ((m (char-code x)))
|
3347 | 3346 | (cond ((< 96 m 123) (code-char (- m 32)))
|
3348 | - ((> m lisp::+unicode-lower-limit+)
|
|
3349 | - (if (member (unicode-category m) '(92 32 75 109))
|
|
3350 | - x
|
|
3351 | - (code-char (lisp::unicode-upper m))))
|
|
3347 | + ((and (> m lisp::+unicode-lower-limit+)
|
|
3348 | + (= (unicode-category m) lisp::+unicode-category-lower+))
|
|
3349 | + (code-char (lisp::unicode-upper m)))
|
|
3352 | 3350 | (t x))))
|
3353 | 3351 | |
3354 | -(deftransform char-downcase ((x) (base-char))
|
|
3352 | +(deftransform char-downcase ((x) (character))
|
|
3355 | 3353 | "open code"
|
3356 | - ;; NOTE: This MUST match what the function char-downcase does.
|
|
3357 | 3354 | #-(and unicode (not unicode-bootstrap))
|
3358 | 3355 | '(if (upper-case-p x)
|
3359 | 3356 | (code-char (+ (char-code x) 32))
|
3360 | 3357 | x)
|
3361 | 3358 | #+(and unicode (not unicode-bootstrap))
|
3362 | 3359 | '(let ((m (char-code x)))
|
3363 | - (cond ((> m lisp::+unicode-lower-limit+)
|
|
3364 | - (if (member (unicode-category m) '(92 75 109))
|
|
3365 | - x
|
|
3366 | - (code-char (lisp::unicode-lower m))))
|
|
3360 | + (cond ((and (> m lisp::+unicode-lower-limit+)
|
|
3361 | + (= (unicode-category m) lisp::+unicode-category-upper+))
|
|
3362 | + (code-char (lisp::unicode-lower m)))
|
|
3367 | 3363 | ((< 64 m 91) (code-char (+ m 32)))
|
3368 | 3364 | (t x))))
|
3369 | 3365 |