Changeset 13650 for release/1.5


Ignore:
Timestamp:
Apr 21, 2010, 4:46:31 PM (10 years ago)
Author:
rme
Message:

Merge r13648 (vector streams fixes)

Location:
release/1.5/source
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/1.5/source

  • release/1.5/source/level-1/l1-streams.lisp

    r13499 r13650  
    61546154                 (declare ((simple-array (unsigned-byte 8) (*)) data)
    61556155                          (fixnum offset))
    6156                  (%copy-ivector-to-ivector new 0 data offset len)
     6156                 (%copy-ivector-to-ivector data 0 new offset len)
    61576157                 (setf (vector-output-stream-ioblock-displacement ioblock) 0)
    61586158                 (unless (= 0 offset)
     
    61766176             (declare (fixnum len newlen)
    61776177                      ((simple-array (unsigned-byte 8) (*)) old new))
    6178              (%copy-ivector-to-ivector new 0 old 0 len)
     6178             (%copy-ivector-to-ivector old 0 new 0 len)
    61796179             (setf (io-buffer-buffer outbuf) new
    61806180                   (io-buffer-size outbuf) newlen
     
    62186218
    62196219
    6220 (defun unsigned-integer-to-binary (value len s)
     6220(defmethod unsigned-integer-to-binary (value len (s binary-output-stream))
     6221  (unless (typep value 'unsigned-byte)
     6222    (report-bad-arg value 'unsigned-byte))
     6223  (do* ((shift (ash (1- len) 3) (- shift 8)))
     6224       ((< shift 0) value)
     6225    (write-byte (logand #xff (ash value (- shift))) s)))
     6226
     6227(defun %unsigned-integer-to-binary (value len s)
    62216228  (declare (fixnum len))
    62226229  (unless (and (typep s 'basic-stream)
     
    62776284             (incf idx))))))))
    62786285
    6279 (defun signed-integer-to-binary (value len s)
     6286(defmethod unsigned-integer-to-binary (value len (s vector-output-stream))
     6287  (%unsigned-integer-to-binary value len s))
     6288
     6289(defun %signed-integer-to-binary (value len s)
    62806290  (declare (fixnum len))
    62816291  (unless (and (typep s 'basic-stream)
     
    63296339                     (aref value #+little-endian-target n #+big-endian-target (the fixnum (logxor n 3)))))
    63306340             (incf idx))))))))
     6341
     6342(defmethod signed-integer-to-binary (value len (s vector-output-stream))
     6343  (%signed-integer-to-binary value len s))
    63316344     
    6332              
     6345(defmethod signed-integer-to-binary (value len (s binary-output-stream))
     6346  (do* ((shift (ash (1- len) 3) (- shift 8)))
     6347       ((< shift 0) value)
     6348    (write-byte (logand #xff (ash value (- shift))) s)))             
    63336349               
    63346350
     
    64686484
    64696485
    6470 
    6471 (defun pui-stream (s count)
     6486(defmethod pui-stream ((s binary-input-stream) count)
     6487  "Parse unsigned integer from a stream."
     6488  (declare (fixnum count)               ; any integer that cannot be expressed in fixnum bytes is probably (ahem) too long to worry about
     6489           (optimize (speed 3) (safety 1) (debug 1)))
     6490  (let ((n 0))
     6491    (dotimes (i count n)
     6492      (declare (fixnum i))
     6493      (setq n (+ (the fixnum (read-byte s)) (the integer (ash n 8)))))))
     6494
     6495(defun %pui-stream (s count)
    64726496  (declare (fixnum count))
    64736497  (unless (and (typep s 'basic-stream)
     
    64916515      result)))
    64926516
    6493 (defun psi-stream (s count)
     6517(defmethod pui-stream ((s vector-input-stream) count)
     6518  (%pui-stream s count))
     6519
     6520(defmethod psi-stream ((s binary-input-stream) count)
     6521  (declare (fixnum count))
     6522  (if (zerop count)
     6523    0
     6524    (let* ((n (read-byte s)))
     6525      (if (>= n 128)
     6526        (setq n (- n 256)))
     6527      (dotimes (i (the fixnum (1- count)) n)
     6528        (setq n (logior (read-byte s) (ash n 8)))))))
     6529
     6530(defun %psi-stream (s count)
    64946531  (declare (fixnum count))
    64956532  (unless (and (typep s 'basic-stream)
     
    65126549      result)))
    65136550
     6551(defmethod psi-stream ((s vector-input-stream) count)
     6552  (%psi-stream s count))
     6553
    65146554(defmethod stream-position ((s vector-input-stream) &optional newpos)
    65156555  (let* ((ioblock (basic-stream-ioblock s))
Note: See TracChangeset for help on using the changeset viewer.