Changeset 10354


Ignore:
Timestamp:
Aug 5, 2008, 11:17:12 AM (11 years ago)
Author:
gb
Message:

WITH-ENCODED-CSTRS: encoding name, not constant encoding object.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lib/macros.lisp

    r10219 r10354  
    16561656(defmacro with-encoded-cstr ((encoding-name (sym string &optional start end))
    16571657                             &rest body &environment env)
    1658   (let* ((encoding (get-character-encoding encoding-name))
    1659          (str (gensym))
    1660          (len (gensym))
    1661          (nzeros (floor (character-encoding-code-unit-size encoding) 8)))
    1662     (collect ((trailing-zeros))
    1663       (case nzeros
    1664         (1 (trailing-zeros `(setf (%get-unsigned-byte ,sym ,len) 0)))
    1665         (2 (trailing-zeros `(setf (%get-unsigned-word ,sym ,len) 0)))
    1666         (4 (trailing-zeros `(setf (%get-unsigned-long ,sym ,len) 0)))
    1667         (t
    1668          (dotimes (i nzeros)
    1669            (trailing-zeros `(setf (%get-unsigned-byte ,sym (the fixnum (+ ,len ,i))) 0)))))
     1658  (let* ((encoding (gensym))
     1659         (str (gensym)))
    16701660      (multiple-value-bind (body decls) (parse-body body env nil)
    1671         `(let* ((,str ,string))
    1672           (%stack-block ((,sym (cstring-encoded-length-in-bytes ,encoding ,str ,start ,end)))
     1661        `(let* ((,str ,string)
     1662                (,encoding (get-character-encoding ,encoding-name)))
     1663          (%stack-block ((,sym (cstring-encoded-length-in-bytes ,encoding ,str ,start ,end) :clear t))
    16731664            ,@decls
    1674             (let* ((,len (encode-string-to-memory ,encoding ,sym 0 ,str ,start ,end)))
    1675               (declare (fixnum ,len))
    1676               ,@(trailing-zeros)
    1677               ,@body)))))))
     1665            (encode-string-to-memory ,encoding ,sym 0 ,str ,start ,end)
     1666            ,@body)))))
    16781667
    16791668(defmacro with-encoded-cstrs (encoding-name bindings &body body)
Note: See TracChangeset for help on using the changeset viewer.