X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;ds=sidebyside;f=strings.lisp;h=6ec3f5ce434465fae964e79855d57da64bd5a88a;hb=91e3d8f38e4ccdfbfb9c351e05b487ee899c9e47;hp=19389e1809564f7d6961f8beb20451ba8acf273d;hpb=79ce9975800c5c9e968c5db342add2d01a5cd83b;p=kmrcl.git diff --git a/strings.lisp b/strings.lisp index 19389e1..6ec3f5c 100644 --- a/strings.lisp +++ b/strings.lisp @@ -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))