+ (return-from pick-input-routine
+ (values (symbol-function (cadr entry))
+ (car entry)
+ (caddr entry)))))
+ ;; FIXME: let's do it the hard way, then (but ignore things like
+ ;; endianness, efficiency, and the necessary coupling between these
+ ;; and the output routines). -- CSR, 2004-02-09
+ (loop for i from 40 by 8 to 1024 ; ARB (well, KLUDGE really)
+ if (subtypep type `(unsigned-byte ,i))
+ do (return-from pick-input-routine
+ (values
+ (lambda (stream eof-error eof-value)
+ (input-wrapper (stream (/ i 8) eof-error eof-value)
+ (let ((sap (fd-stream-ibuf-sap stream))
+ (head (fd-stream-ibuf-head stream)))
+ (loop for j from 0 below (/ i 8)
+ with result = 0
+ do (setf result
+ (+ (* 256 result)
+ (sap-ref-8 sap (+ head j))))
+ finally (return result)))))
+ `(unsigned-byte ,i)
+ (/ i 8))))
+ (loop for i from 40 by 8 to 1024 ; ARB (well, KLUDGE really)
+ if (subtypep type `(signed-byte ,i))
+ do (return-from pick-input-routine
+ (values
+ (lambda (stream eof-error eof-value)
+ (input-wrapper (stream (/ i 8) eof-error eof-value)
+ (let ((sap (fd-stream-ibuf-sap stream))
+ (head (fd-stream-ibuf-head stream)))
+ (loop for j from 0 below (/ i 8)
+ with result = 0
+ do (setf result
+ (+ (* 256 result)
+ (sap-ref-8 sap (+ head j))))
+ finally (return (if (logbitp (1- i) result)
+ (dpb result (byte i 0) -1)
+ result))))))
+ `(signed-byte ,i)
+ (/ i 8)))))
+
+;;; Return a string constructed from SAP, START, and END.