- (restart-case
- (unless (block character-decode
- (let ((byte (sap-ref-8 sap head)))
- (setq size ,in-size-expr)
- (when (> size (- tail head))
- (return))
- (setf (aref buffer (+ start total-copied))
- ,in-expr)
- (incf total-copied)
- (incf head size)))
- (setf (fd-stream-ibuf-head stream) head)
- (if (plusp total-copied)
- (return-from ,in-function total-copied)
- (stream-decoding-error
- stream
- (if size
- (loop for i from 0 below size
- collect (sap-ref-8 (fd-stream-ibuf-sap
- stream)
- (+ (fd-stream-ibuf-head
- stream)
- i)))
- (list (sap-ref-8 (fd-stream-ibuf-sap stream)
- (fd-stream-ibuf-head stream)))))))
- (attempt-resync ()
- :report (lambda (stream)
- (format stream
- "~@<Attempt to resync the stream at a ~
- character boundary and continue.~@:>"))
- (,resync-function stream)
- (setf head (fd-stream-ibuf-head stream)))
- (force-end-of-file ()
- :report (lambda (stream)
- (format stream "~@<Force an end of file.~@:>"))
+ (setf decode-break-reason
+ (block decode-break-reason
+ (let ((byte (sap-ref-8 sap head)))
+ (setq size ,in-size-expr)
+ (when (> size (- tail head))
+ (return))
+ (setf (aref buffer (+ start total-copied)) ,in-expr)
+ (incf total-copied)
+ (incf head size))
+ nil))
+ (setf (fd-stream-ibuf-head stream) head)
+ (when (and decode-break-reason
+ (= head head-start))
+ (when (stream-decoding-error-and-handle
+ stream decode-break-reason)