X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=strings.lisp;h=028d97870c2fa4aacc96f5955f9fa1cabed95e8f;hb=a0d3f176d56e57259898d37883fe81c3cf4ed896;hp=91e51987e8511608f40e758a4ed484e1eef863a6;hpb=85e0b81ffb73be94a9954ae2034bd0067ba6c221;p=kmrcl.git diff --git a/strings.lisp b/strings.lisp index 91e5198..028d978 100644 --- a/strings.lisp +++ b/strings.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: strings.lisp,v 1.13 2003/04/29 00:46:35 kevin Exp $ +;;;; $Id: strings.lisp,v 1.17 2003/05/04 14:52:10 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -59,6 +59,16 @@ do (setf start (1+ end)))) +(defun ndelimited-string-to-list (sequence &optional (separator #\space)) + "Split a string by a delimitor" + (loop + with start = 0 + for end = (position separator sequence :start start) + collect (nsubseq sequence start end) + until (null end) + do + (setf start (1+ end)))) + #+excl (defun list-to-delimited-string (list &optional (separator #\space)) (excl:list-to-delimited-string list separator)) @@ -115,6 +125,13 @@ (subseq s 0 (1- len)) s))) +(defun nstring-trim-last-character (s) + "Return the string less the last character" + (let ((len (length s))) + (if (plusp len) + (nsubseq s 0 (1- len)) + s))) + (defun string-hash (str &optional (bitmask 65535)) (let ((hash 0)) (declare (fixnum hash) @@ -184,7 +201,7 @@ list of characters and replacement strings." (defun escape-xml-string (string) "Escape invalid XML characters" (substitute-chars-strings - string '((#\& . "&") (#\> . ">") (#\< . "<")))) + string '((#\& . "&") (#\> . ">") (#\< . "<") (#\" . """)))) (defun make-usb8-array (len)