Raymond Toy pushed to branch issue-323-cl-string-casing at cmucl / cmucl

Commits:

2 changed files:

Changes:

  • src/code/string.lisp
    ... ... @@ -804,6 +804,7 @@
    804 804
     	  (setf (schar newstring new-index) (schar string index)))
    
    805 805
     	newstring))))
    
    806 806
     
    
    807
    +#+nil
    
    807 808
     (defun nstring-upcase (string &key (start 0) end)
    
    808 809
       "Given a string, returns that string with all lower case alphabetic
    
    809 810
       characters converted to uppercase."
    
    ... ... @@ -828,6 +829,20 @@
    828 829
     	      (setf (schar string (incf index)) lo))))))
    
    829 830
         save-header))
    
    830 831
     
    
    832
    +(defun nstring-upcase (string &key (start 0) end)
    
    833
    +  "Given a string, returns that string with all lower case alphabetic
    
    834
    +  characters converted to uppercase."
    
    835
    +  (declare (fixnum start))
    
    836
    +  (let ((save-header string))
    
    837
    +    (with-one-string string start end offset
    
    838
    +      (do ((index start (1+ index)))
    
    839
    +	  ((= index (the fixnum end)))
    
    840
    +	(declare (fixnum index))
    
    841
    +        (setf (schar string index)
    
    842
    +              (char-upcase (schar string index))))
    
    843
    +    save-header)))
    
    844
    +
    
    845
    +#+nil
    
    831 846
     (defun nstring-downcase (string &key (start 0) end)
    
    832 847
       "Given a string, returns that string with all upper case alphabetic
    
    833 848
       characters converted to lowercase."
    
    ... ... @@ -852,6 +867,19 @@
    852 867
     	      (setf (schar string (incf index)) lo))))))
    
    853 868
         save-header))
    
    854 869
     
    
    870
    +(defun nstring-downcase (string &key (start 0) end)
    
    871
    +  "Given a string, returns that string with all upper case alphabetic
    
    872
    +  characters converted to lowercase."
    
    873
    +  (declare (fixnum start))
    
    874
    +  (let ((save-header string))
    
    875
    +    (with-one-string string start end offset
    
    876
    +      (do ((index start (1+ index)))
    
    877
    +	  ((= index (the fixnum end)))
    
    878
    +	(declare (fixnum index))
    
    879
    +        (setf (schar string index)
    
    880
    +              (char-downcase (schar string index)))))
    
    881
    +    save-header))
    
    882
    +
    
    855 883
     (defun nstring-capitalize (string &key (start 0) end)
    
    856 884
       "Given a string, returns that string with the first
    
    857 885
       character of each ``word'' converted to upper-case, and remaining
    

  • tests/string.lisp
    ... ... @@ -8,11 +8,10 @@
    8 8
     (defun make-test-string ()
    
    9 9
       ;; Create a string consisting of all the code units EXCEPT for the
    
    10 10
       ;; surrogates because string casing handles that differently.
    
    11
    -  (coerce
    
    12
    -   (loop for code from 0 to #xffff
    
    13
    -         unless (lisp::surrogatep code)
    
    14
    -         collect (code-char code))
    
    15
    -   'string))
    
    11
    +  (let ((s (make-string char-code-limit)))
    
    12
    +    (dotimes (k char-code-limit)
    
    13
    +      (setf (aref s k) (code-char k)))
    
    14
    +    s))
    
    16 15
     
    
    17 16
     (define-test string-upcase
    
    18 17
         (:tag :issues)