[Git][cmucl/cmucl][issue-323-cl-string-casing] More cleanups
![](https://secure.gravatar.com/avatar/5634a99cd64dd70d4a6692c3031a1284.jpg?s=120&d=mm&r=g)
Raymond Toy pushed to branch issue-323-cl-string-casing at cmucl / cmucl Commits: e3862c75 by Raymond Toy at 2024-06-03T09:58:23-07:00 More cleanups Just use simple `(string string)` instead of doing a test for `stringp`. Fix bad formatting in `string-upcase-full`. Use `ecase` as needed and also add declarations to it clearer to the compiler what the acceptable arguments are. Also, we were confused on what `string-capitalize-simple` does compared to `string-capitalize-full`. We call `string-capitalize-simple` if the `casing` arg is `:simple-title` instead of `:simple`, which should call `string-capitalize-full`. - - - - - 1 changed file: - src/code/unicode.lisp Changes: ===================================== src/code/unicode.lisp ===================================== @@ -21,7 +21,7 @@ _N"Given a string, returns a new string that is a copy of it with all lower case alphabetic characters converted to uppercase." (declare (fixnum start)) - (let* ((string (if (stringp string) string (string string))) + (let* ((string (string string)) (slen (length string))) (declare (fixnum slen)) (lisp::with-one-string string start end offset @@ -66,8 +66,8 @@ _N"Given a string, returns a new string that is a copy of it with all lower case alphabetic characters converted to uppercase using full case conversion." - (declare (fixnum start)) (let* ((string (if - (stringp string) string (string string))) + (declare (fixnum start)) + (let* ((string (string string)) (slen (length string))) (declare (fixnum slen)) (with-output-to-string (s) @@ -100,10 +100,13 @@ all lower case alphabetic characters converted to uppercase. Casing is :simple or :full for simple or full case conversion, respectively." - (declare (fixnum start)) - (if (eq casing :simple) - (string-upcase-simple string :start start :end end) - (string-upcase-full string :start start :end end))) + (declare (fixnum start) + (type (member :simple :full) casing)) + (ecase casing + (:simple + (string-upcase-simple string :start start :end end)) + (:full + (string-upcase-full string :start start :end end)))) (defun string-downcase-simple (string &key (start 0) end) _N"Given a string, returns a new string that is a copy of it with all @@ -188,10 +191,13 @@ uppercase alphabetic characters converted to lowercase. Casing is :simple or :full for simple or full case conversion, respectively." - (declare (fixnum start)) - (if (eq casing :simple) - (string-downcase-simple string :start start :end end) - (string-downcase-full string :start start :end end))) + (declare (fixnum start) + (type (member :simple :full) casing)) + (ecase casing + (:simple + (string-downcase-simple string :start start :end end)) + (:full + (string-downcase-full string :start start :end end)))) ;;; @@ -637,12 +643,14 @@ delimited by non-case-modifiable chars. " (declare (fixnum start) - (type (member :simple :full :title) casing)) + (type (member :simple-title :simple :full :title) casing)) (if unicode-word-break (string-capitalize-unicode string :start start :end end :casing casing) - (if (eq casing :simple) - (string-capitalize-simple string :start start :end end) - (string-capitalize-full string :start start :end end :casing casing)))) + (ecase casing + (:simple-title + (string-capitalize-simple string :start start :end end)) + ((:simple :full :title) + (string-capitalize-full string :start start :end end :casing casing))))) (defun decompose-hangul-syllable (cp stream) View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/e3862c755851d5df523f9225... -- This project does not include diff previews in email notifications. View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/e3862c755851d5df523f9225... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)