... |
... |
@@ -676,6 +676,49 @@ |
676
|
676
|
(setf (schar newstring new-index) (schar string index)))
|
677
|
677
|
newstring))))
|
678
|
678
|
|
|
679
|
+#+nil
|
|
680
|
+(defun string-capitalize (string &key (start 0) end)
|
|
681
|
+ _N"Given a string, returns a copy of the string with the first
|
|
682
|
+ character of each ``word'' converted to upper-case, and remaining
|
|
683
|
+ chars in the word converted to lower case. A ``word'' is defined
|
|
684
|
+ to be a string of case-modifiable characters delimited by
|
|
685
|
+ non-case-modifiable chars."
|
|
686
|
+ (declare (fixnum start))
|
|
687
|
+ (let* ((string (if (stringp string) string (string string)))
|
|
688
|
+ (slen (length string)))
|
|
689
|
+ (declare (fixnum slen))
|
|
690
|
+ (with-one-string string start end offset
|
|
691
|
+ (let ((offset-slen (+ slen offset))
|
|
692
|
+ (newstring (make-string slen)))
|
|
693
|
+ (declare (fixnum offset-slen))
|
|
694
|
+ (do ((index offset (1+ index))
|
|
695
|
+ (new-index 0 (1+ new-index)))
|
|
696
|
+ ((= index start))
|
|
697
|
+ (declare (fixnum index new-index))
|
|
698
|
+ (setf (schar newstring new-index) (schar string index)))
|
|
699
|
+ (do ((index start (1+ index))
|
|
700
|
+ (new-index (- start offset) (1+ new-index))
|
|
701
|
+ (newword t)
|
|
702
|
+ (char ()))
|
|
703
|
+ ((= index (the fixnum end)))
|
|
704
|
+ (declare (fixnum index new-index))
|
|
705
|
+ (setq char (schar string index))
|
|
706
|
+ (cond ((not (alphanumericp char))
|
|
707
|
+ (setq newword t))
|
|
708
|
+ (newword
|
|
709
|
+ ;;char is first case-modifiable after non-case-modifiable
|
|
710
|
+ (setq char (char-upcase char))
|
|
711
|
+ (setq newword ()))
|
|
712
|
+ ;;char is case-modifiable, but not first
|
|
713
|
+ (t (setq char (char-downcase char))))
|
|
714
|
+ (setf (schar newstring new-index) char))
|
|
715
|
+ (do ((index end (1+ index))
|
|
716
|
+ (new-index (- (the fixnum end) offset) (1+ new-index)))
|
|
717
|
+ ((= index offset-slen))
|
|
718
|
+ (declare (fixnum index new-index))
|
|
719
|
+ (setf (schar newstring new-index) (schar string index)))
|
|
720
|
+ newstring))))
|
|
721
|
+
|
679
|
722
|
(defun string-capitalize (string &key (start 0) end)
|
680
|
723
|
_N"Given a string, returns a copy of the string with the first
|
681
|
724
|
character of each ``word'' converted to upper-case, and remaining
|
... |
... |
@@ -719,7 +762,7 @@ |
719
|
762
|
newstring))))
|
720
|
763
|
|
721
|
764
|
(defun nstring-upcase (string &key (start 0) end)
|
722
|
|
- "Given a string, returns that string with all lower case alphabetic
|
|
765
|
+ _N"Given a string, returns that string with all lower case alphabetic
|
723
|
766
|
characters converted to uppercase."
|
724
|
767
|
(declare (fixnum start))
|
725
|
768
|
(let ((save-header string))
|
... |
... |
@@ -732,7 +775,7 @@ |
732
|
775
|
save-header)))
|
733
|
776
|
|
734
|
777
|
(defun nstring-downcase (string &key (start 0) end)
|
735
|
|
- "Given a string, returns that string with all upper case alphabetic
|
|
778
|
+ _N"Given a string, returns that string with all upper case alphabetic
|
736
|
779
|
characters converted to lowercase."
|
737
|
780
|
(declare (fixnum start))
|
738
|
781
|
(let ((save-header string))
|
... |
... |
@@ -744,6 +787,7 @@ |
744
|
787
|
(char-downcase (schar string index)))))
|
745
|
788
|
save-header))
|
746
|
789
|
|
|
790
|
+#+nil
|
747
|
791
|
(defun nstring-capitalize (string &key (start 0) end)
|
748
|
792
|
"Given a string, returns that string with the first
|
749
|
793
|
character of each ``word'' converted to upper-case, and remaining
|
... |
... |
@@ -769,6 +813,31 @@ |
769
|
813
|
(setf (schar string index) (char-downcase char))))))
|
770
|
814
|
save-header))
|
771
|
815
|
|
|
816
|
+(defun nstring-capitalize (string &key (start 0) end)
|
|
817
|
+ _N"Given a string, returns that string with the first
|
|
818
|
+ character of each ``word'' converted to upper-case, and remaining
|
|
819
|
+ chars in the word converted to lower case. A ``word'' is defined
|
|
820
|
+ to be a string of case-modifiable characters delimited by
|
|
821
|
+ non-case-modifiable chars."
|
|
822
|
+ (declare (fixnum start))
|
|
823
|
+ (let ((save-header string))
|
|
824
|
+ (with-one-string string start end offset
|
|
825
|
+ (do ((index start (1+ index))
|
|
826
|
+ (newword t)
|
|
827
|
+ (char ()))
|
|
828
|
+ ((= index (the fixnum end)))
|
|
829
|
+ (declare (fixnum index))
|
|
830
|
+ (setq char (schar string index))
|
|
831
|
+ (cond ((not (alphanumericp char))
|
|
832
|
+ (setq newword t))
|
|
833
|
+ (newword
|
|
834
|
+ ;;char is first case-modifiable after non-case-modifiable
|
|
835
|
+ (setf (schar string index) (char-upcase char))
|
|
836
|
+ (setq newword ()))
|
|
837
|
+ (t
|
|
838
|
+ (setf (schar string index) (char-downcase char))))))
|
|
839
|
+ save-header))
|
|
840
|
+
|
772
|
841
|
|
773
|
842
|
#+unicode
|
774
|
843
|
(progn
|