X-Git-Url: http://git.kpe.io/?p=kmrcl.git;a=blobdiff_plain;f=strings.lisp;h=fbb130caad55b5d4442653f43d1d57290354bd4a;hp=9dbe1babdccd7950172033dc0d5c6d9614ff4921;hb=12e4f3260043dbc89dc8efd78cb9f116e0173054;hpb=e9927af19ebf762b2311f296643c00e3aa9cbb00 diff --git a/strings.lisp b/strings.lisp index 9dbe1ba..fbb130c 100644 --- a/strings.lisp +++ b/strings.lisp @@ -227,17 +227,20 @@ list of characters and replacement strings." (defun make-usb8-array (len) (make-array len :element-type '(unsigned-byte 8))) -(defun usb8-array-to-string (vec) - (declare (type (simple-array (unsigned-byte 8) (*)) vec)) - (let* ((len (length vec)) +(defun usb8-array-to-string (vec &key (start 0) end) + (declare (type (simple-array (unsigned-byte 8) (*)) vec) + (fixnum start)) + (unless end + (setq end (length vec))) + (let* ((len (- end start)) (str (make-string len))) (declare (fixnum len) (simple-string str) - (optimize (speed 3))) + (optimize (speed 3) (safety 0))) (do ((i 0 (1+ i))) ((= i len) str) (declare (fixnum i)) - (setf (schar str i) (code-char (aref vec i)))))) + (setf (schar str i) (code-char (aref vec (the fixnum (+ i start)))))))) (defun string-to-usb8-array (str) (declare (simple-string str)) @@ -413,9 +416,9 @@ for characters in a string" (declare (type (integer 0 15) n)) (schar +hex-chars+ n)) -(defconst +char-code-lower-a+ (char-code #\a)) -(defconst +char-code-upper-a+ (char-code #\A)) -(defconst +char-code-0+ (char-code #\0)) +(defconstant* +char-code-lower-a+ (char-code #\a)) +(defconstant* +char-code-upper-a+ (char-code #\A)) +(defconstant* +char-code-0+ (char-code #\0)) (declaim (type fixnum +char-code-0+ +char-code-upper-a+ +char-code-0)) @@ -478,7 +481,7 @@ for characters in a string" (eval-when (:compile-toplevel :load-toplevel :execute) (defvar +unambiguous-charset+ "abcdefghjkmnpqrstuvwxyz123456789ABCDEFGHJKLMNPQSRTUVWXYZ") - (defconstant +unambiguous-length+ (length +unambiguous-charset+))) + (defconstant* +unambiguous-length+ (length +unambiguous-charset+))) (defun random-char (&optional (set :lower-alpha)) (ecase set @@ -648,7 +651,6 @@ for characters in a string" word))) - (defun collapse-whitespace (s) "Convert multiple whitespace characters to a single space character." (declare (simple-string s)