[add lazyWriteCFF, fix lazyReadCFF.
John Meacham <john@repetae.net>**20070829014509] hunk ./Support/CFF.hs 18
+    lazyWriteCFF,
hunk ./Support/CFF.hs 33
+import qualified Data.Map as Map
hunk ./Support/CFF.hs 35
-newtype ChunkType = ChunkType Word32
-    deriving(Eq,Ord)
hunk ./Support/CFF.hs 47
+-----------------------------------
+-- Routines dealing with ChunkTypes
+-----------------------------------
+
+newtype ChunkType = ChunkType Word32
+    deriving(Eq,Ord)
hunk ./Support/CFF.hs 64
+chunkType [b1,b2,b3] = chunkType [b1,b2,b3,' ']
hunk ./Support/CFF.hs 151
-            if ct == ect
-            then do
-                BS.hGet h (fromIntegral len)
-            else do
+            if ct == ect then do BS.hGet h (fromIntegral len) else do
hunk ./Support/CFF.hs 157
-writeCFF :: Handle -> (ChunkType,[(ChunkType,BS.ByteString)]) -> IO ()
-writeCFF h (ft,xs) = do
+writeCFF :: Handle -> ChunkType -> [(ChunkType,BS.ByteString)] -> IO ()
+writeCFF h ft xs = do
hunk ./Support/CFF.hs 167
+lazyWriteCFF :: Handle -> ChunkType -> [(ChunkType,LBS.ByteString)] -> IO ()
+lazyWriteCFF h ft xs = do
+    writeCFFHeader h ft
+    let writeChunk (ChunkType ct,bs) = do
+            writeWord32 h (fromIntegral $ LBS.length bs)
+            writeWord32 h ct
+            LBS.hPut h bs
+            writeWord32 h 0 -- TODO proper checksum
+    mapM_ writeChunk xs
hunk ./Support/CFF.hs 180
-    mv <- newMVar ()
+    mv <- newEmptyMVar
hunk ./Support/CFF.hs 185
-            return (Map.fromList xs'')
+                xs''' = [ (ct,map snd xs) | xs@((ct,_):_) <- xs'' ]
+            return (Map.fromList xs''')
hunk ./Support/CFF.hs 190
-            len <- readWord32 h
+            len <- fromIntegral `fmap` readWord32 h
hunk ./Support/CFF.hs 193
+            hSeek h RelativeSeek (fromIntegral len)
+            hSeek h RelativeSeek 4
hunk ./Support/CFF.hs 198
-                BS.hGet h (fromIntegral len)
+                res <- BS.hGet h len
hunk ./Support/CFF.hs 200
-            hSeek h RelativeSeek 4
+                return res
hunk ./Support/CFF.hs 206
+    putMVar mv ()