commit 6e32c8bc706b32b633157d46f2ccd4feb9d37b6f parent be6a342c5a7046b5bd023bf461a9031bd45f2058 Author: Tomas Hlavaty <tom@logand.com> Date: Sun, 20 Sep 2015 18:14:58 +0200 bit-reader added Diffstat:
M | rw.lisp | | | 15 | +++++++++++++++ |
1 file changed, 15 insertions(+), 0 deletions(-)
diff --git a/rw.lisp b/rw.lisp @@ -23,6 +23,7 @@ (defpackage :rw (:use :cl) (:export :*endian* + :bit-reader :byte-reader :byte-writer :char-reader @@ -333,6 +334,20 @@ (when x (parse-integer (coerce x 'string) :radix radix)))) +(defun bit-reader (octet-reader) + (let (octet bit) + (lambda () + (unless octet + (setq octet (rw:next octet-reader) + bit 7)) + (when octet + (prog1 (if (logbitp bit octet) 1 0) + (if (plusp bit) + (decf bit) + (setq octet nil))))))) + +;;(rw:till (rw:peek-reader (bit-reader (rw:reader '(#b10110111 #b01111011))))) + ;; TODO next-u64|128 ;; TODO next-s8|16|32|64|128