on master help sign in
Reorder exports in BitGet and cleanup a bit
commit554c906d0cf3fe96d957ebd1655a578d70259b02 authorLennart Kolmodin <kolmodin@gentoo.org> dateFri 27 Aug 2010, 17:03 (16 years ago) parent2d75d41
1 file changed+9−8
BitsGet.hs+9−8
BitsGet.hs+9−8
@@ -1,13 +1,7 @@
11{-# LANGUAGE GADTs, RankNTypes, MagicHash, CPP #-}
22
33module BitsGet
4− ( -- R(..),
5− T(..)
6− -- , get
7− -- , getR
8− , readBool
9− , readWord8
10− , readWord16be
4+ ( T(..)
115 , runBitGet
126 , runBitGetSimple
137 , BitGet
@@ -16,6 +10,10 @@ module BitsGet
1610 , getWord16be
1711 , getWord32be
1812
13+ , readBool
14+ , readWord8
15+ , readWord16be
16+
1917 ) where
2018
2119import Data.Binary.Get ( runGet, Get, needMore, getByteString, getS, putS )
@@ -136,13 +134,16 @@ readWithoutOffset s@(S bs o) shifterL shifterR n
136134 in (bn (segs-1) :*: incS s n)
137135
138136 | n <= 64 = let segs = byte_offset n
137+ o' = bit_offset (n - 8 + o)
139138
140139 bn 0 = fromIntegral (unsafeHead bs)
141140 bn n = (bn (n-1) `shifterL` 8) .|. fromIntegral (unsafeIndex bs n)
142141
142+ msegs = bn segs `shifterL` o'
143+
143144 last = (fromIntegral (unsafeIndex bs (segs + 1))) `shifterR` (8 - (bit_offset n))
144145
145− w = bn segs .|. last
146+ w = msegs .|. last
146147 in w :*: incS s n
147148
148149readWithOffset s@(S bs o) shifterL shifterR n