r5339: *** empty log message ***
[kmrcl.git] / strings.lisp
index 19389e1809564f7d6961f8beb20451ba8acf273d..6ec3f5ce434465fae964e79855d57da64bd5a88a 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Apr 2000
 ;;;;
-;;;; $Id: strings.lisp,v 1.48 2003/07/16 16:01:37 kevin Exp $
+;;;; $Id: strings.lisp,v 1.49 2003/07/19 20:32:48 kevin Exp $
 ;;;;
 ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
@@ -540,3 +540,24 @@ for characters in a string"
        (return-from string-strip-ending
          (subseq str 0 (- len (length ending))))))))
        
+
+(defun string-maybe-shorten (str maxlen)
+  (let ((len (length str)))
+    (if (<= len maxlen)
+       str
+      (concatenate 'string (subseq str 0 (- maxlen 3)) "..."))))
+
+
+(defun shrink-vector (str size)
+  #+allegro
+  (excl::.primcall 'sys::shrink-svector str size)
+  #+sbcl
+  (sb-kernel:shrink-vector str size)
+  #+cmu
+  (lisp::shrink-vector str size)
+  #+lispworks
+  (system::shrink-vector$vector str size)
+  #+(or allegro cmu sbcl lispworks)
+  str
+  #-(or allegro cmu sbcl lispworks)
+  (subseq str 0 size))