[Ecls-list] Unknown type '(UNSIGNED-BYTE 8). Assuming it is T.

Matthew Mondor mm_lists at pulsar-zone.net
Fri Sep 2 10:33:13 UTC 2011


Hello again,

I have a file which when compiling the compiler often complains about
the '(UNSIGNED-BYTE 8) type being unknown.  Interestingly, when I
recompile the same file just afterwards, this no longer occurs.


;;; Compiling (DEFUN URL-DECODE ...).
;;; Note:
;;;   in file test-httpd.lisp, position 14553
;;;   at (DEFUN URL-DECODE ...)
;;;   Unknown type '(UNSIGNED-BYTE 8). Assuming it is T.
;;; Note:
;;;   in file test-httpd.lisp, position 14553
;;;   at (DEFUN URL-DECODE ...)
;;;   Unknown type '(UNSIGNED-BYTE 8). Assuming it is T.


I'm not sure this is totally harmless (unless it's the warning that's
wrong and spurious), because in that particular case it's important
that the vector contain 8-bit octets (unfortunately, I'm not sure if
the position reported is the one in MAKE-ARRAY or FOR O (I should check
if emacs allows jumping at byte positions, though)...

Here is the function for which these notes happen:


;;; Decodes the URL supplied in STRING to another string, returning it.
(defun url-decode (string)
  (macrolet ((get-octet ()
               `(if (= input-max input-pos)
                    (loop-finish)
                    (prog1
                        (aref input input-pos)
                      (the fixnum (incf (the fixnum input-pos))))))
             (put-octet (o)
               `(vector-push ,o output)))
    (loop
       with input = (utf-8-string-encode string)
       with input-pos of-type fixnum = 0
       with input-max of-type fixnum = (length input)
       with output = (make-array (length input)
                                 :element-type '(unsigned-byte 8)
                                 :fill-pointer 0)
       for o of-type '(unsigned-byte 8) = (get-octet)
       when (= 37 o) do (let ((c1 (code-char (get-octet)))
                              (c2 (code-char (get-octet))))
                          (when (and (digit-char-p c1 16)
                                     (digit-char-p c2 16))
                            (put-octet (parse-integer
                                        (map 'string #'identity
`(,c1 ,c2)) :radix 16))))
       else when (= 43 o) do (put-octet 32)
       else do (put-octet o)
       finally (return (utf-8-string-decode output)))))


Thanks again,
-- 
Matt




More information about the ecl-devel mailing list