X-Git-Url: http://git.kpe.io/?p=cl-base64.git;a=blobdiff_plain;f=decode.lisp;h=6503b78ff49ac3e2be729d31e4344b32fc6337f9;hp=775bb8ef92ef512777b3d36d8cbe7ea1cc1bd3cf;hb=56e48798e60a85073dc6146f3266e0703908fbd0;hpb=8d11e40eb06556b995b963ee7c72e59a5368d21e diff --git a/decode.lisp b/decode.lisp index 775bb8e..6503b78 100644 --- a/decode.lisp +++ b/decode.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Dec 2002 ;;;; -;;;; $Id: decode.lisp,v 1.2 2003/01/12 22:32:40 kevin Exp $ +;;;; $Id$ ;;;; ;;;; This file implements the Base64 transfer encoding algorithm as ;;;; defined in RFC 1521 by Borensten & Freed, September 1993. @@ -19,8 +19,6 @@ ;;;; Permission to use with BSD-style license included in the COPYING file ;;;; ************************************************************************* -(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0))) - (in-package #:cl-base64) (declaim (inline whitespace-p)) @@ -37,13 +35,13 @@ (defmacro def-base64-stream-to-* (output-type) `(defun ,(intern (concatenate 'string (symbol-name :base64-stream-to-) (symbol-name output-type))) - (input &key (uri nil) + (input &key (uri nil) ,@(when (eq output-type :stream) '(stream))) ,(concatenate 'string "Decode base64 stream to " (string-downcase (symbol-name output-type))) (declare (stream input) - (optimize (speed 3))) + (optimize (speed 3) (space 0) (safety 0))) (let ((pad (if uri *uri-pad-char* *pad-char*)) (decode-table (if uri *uri-decode-table* *decode-table*))) (declare (type decode-table decode-table) @@ -61,7 +59,7 @@ (:string '((simple-string result))) (:usb8-array - '((type (array fixnum (*)) result)))) + '((type (simple-array (usigned-byte 8) (*)) result)))) (fixnum ridx)) (do* ((bitstore 0) (bitcount 0) @@ -71,8 +69,11 @@ ,(case output-type (:stream 'stream) - ((or :stream :string) - '(subseq result 0 ridx)))) + ((:string :usb8-array) + 'result) + ;; ((:stream :string) + ;; '(subseq result 0 ridx)))) + )) (declare (fixnum bitstore bitcount) (character char)) (let ((svalue (aref decode-table (the fixnum (char-code char))))) @@ -119,13 +120,13 @@ (defmacro def-base64-string-to-* (output-type) `(defun ,(intern (concatenate 'string (symbol-name :base64-string-to-) (symbol-name output-type))) - (input &key (uri nil) + (input &key (uri nil) ,@(when (eq output-type :stream) '(stream))) ,(concatenate 'string "Decode base64 string to " (string-downcase (symbol-name output-type))) (declare (string input) - (optimize (speed 3))) + (optimize (speed 3) (safety 0) (space 0))) (let ((pad (if uri *uri-pad-char* *pad-char*)) (decode-table (if uri *uri-decode-table* *decode-table*))) (declare (type decode-table decode-table) @@ -143,7 +144,7 @@ (:string '((simple-string result))) (:usb8-array - '((type (array fixnum (*)) result)))) + '((type (simple-array (unsigned-byte 8) (*)) result)))) (fixnum ridx)) (loop for char of-type character across input @@ -189,7 +190,7 @@ ,(case output-type (:stream 'stream) - ((:stream :string) + ((:usb8-array :string) '(subseq result 0 ridx))))))) (def-base64-string-to-* :string) @@ -202,7 +203,7 @@ (defun base64-string-to-integer (string &key (uri nil)) "Decodes a base64 string to an integer" (declare (string string) - (optimize (speed 3))) + (optimize (speed 3) (safety 0) (space 0))) (let ((pad (if uri *uri-pad-char* *pad-char*)) (decode-table (if uri *uri-decode-table* *decode-table*))) (declare (type decode-table decode-table) @@ -230,7 +231,7 @@ (defun base64-stream-to-integer (stream &key (uri nil)) "Decodes a base64 string to an integer" (declare (stream stream) - (optimize (speed 3))) + (optimize (speed 3) (space 0) (safety 0))) (let ((pad (if uri *uri-pad-char* *pad-char*)) (decode-table (if uri *uri-decode-table* *decode-table*))) (declare (type decode-table decode-table)