on master help sign in
Guard getByteString for negative numbers.

Return the empty string if n<=0.

commit9443d4e9c87492b6717a79c7699d2460d7eca094 authorLennart Kolmodin <kolmodin@google.com> dateThu 1 Mar 2012, 22:55 (15 years ago) parent3bb50f1
1 file changed+2−1
Data/Binary/Bits/Get.hs+2−1
Data/Binary/Bits/Get.hs+2−1
@@ -419,7 +419,8 @@ word64be n = Block n (readWord64be n)
419419
420420-- | Read @n@ bytes as a 'ByteString'.
421421byteString :: Int -> Block ByteString
422−byteString n = Block (n*8) (readByteString n)
422+byteString n | n > 0 = Block (n*8) (readByteString n)
423+ | otherwise = Block 0 (\_ -> B.empty)
423424
424425------------------------------------------------------------------------
425426-- Unchecked shifts, from the package binary