[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36
John Goerzen
jgoerzen at complete.org
Fri Apr 23 14:49:59 UTC 2010
The following commit has been merged in the master branch:
commit df75273210461da26ed43653adf084c60c48a005
Author: John Goerzen <jgoerzen at complete.org>
Date: Sat Dec 4 11:20:48 2004 +0100
Checkpointing
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.7--patch-38)
diff --git a/ChangeLog b/ChangeLog
index 536e36c..0661449 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,19 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.7
#
+2004-12-04 04:20:48 GMT John Goerzen <jgoerzen at complete.org> patch-38
+
+ Summary:
+ Checkpointing
+ Revision:
+ missingh--head--0.7--patch-38
+
+
+ modified files:
+ ChangeLog libsrc/MissingH/FileArchive/GZip.hs
+ testsrc/GZiptest.hs
+
+
2004-12-04 03:56:47 GMT John Goerzen <jgoerzen at complete.org> patch-37
Summary:
diff --git a/libsrc/MissingH/FileArchive/GZip.hs b/libsrc/MissingH/FileArchive/GZip.hs
index 5b2bd5a..3023de5 100644
--- a/libsrc/MissingH/FileArchive/GZip.hs
+++ b/libsrc/MissingH/FileArchive/GZip.hs
@@ -21,7 +21,9 @@ The GZip format is described in RFC1952
module MissingH.FileArchive.GZip (
decompress,
read_header,
- Header(..)
+ Header(..),
+ read_section,
+ read_sections
)
where
@@ -57,6 +59,13 @@ data Header = Header {
os :: Int
} deriving (Eq, Show)
+data Footer = Footer {
+ size :: Word32,
+ crc32 :: Word32,
+ crc32valid :: Bool}
+
+type Section = (Header, String, Footer)
+
split1 :: String -> (Char, String)
split1 s = (head s, tail s)
@@ -72,23 +81,24 @@ decompress s =
-}
decompress s = do x <- read_sections s
- return $ concatMap snd x
+ return $ concatMap (\(_, x, _) -> x) x
--- | Read all sections. Returns (Header, ThisSection)
-read_sections :: String -> Either GZipError [(Header, String)]
+-- | Read all sections.
+read_sections :: String -> Either GZipError [Section]
read_sections [] = Right []
-read_sections s = do x <- read_section s
- case x of
- (head, this, remain) -> do
- next <- read_sections remain
- return $ (head, this) : next
+read_sections s =
+ do x <- read_section s
+ case x of
+ (sect, remain) ->
+ do next <- read_sections remain
+ return $ sect : next
parseword :: String -> Word32
parseword s = fromBytes $ map (fromIntegral . ord) $ reverse s
--- | Read one section, returning (Header, ThisSection, Remainder)
-read_section :: String -> Either GZipError (Header, String, String)
+-- | Read one section, returning (ThisSection, Remainder)
+read_section :: String -> Either GZipError (Section, String)
read_section s =
do x <- read_header s
let headerrem = snd x
@@ -96,14 +106,11 @@ read_section s =
let (crc32str, rem) = splitAt 4 remainder
let (sizestr, rem2) = splitAt 4 rem
let filecrc32 = parseword crc32str
-
- if filecrc32 == crc32
- then return $ (fst x, decompressed, rem2)
- else throwError $ "CRC MISMATCH; calculated: " ++
- (show crc32)
- ++ ", recorded: " ++ (show filecrc32)
-
-
+ let filesize = parseword sizestr
+ return ((fst x, decompressed,
+ Footer {size = filesize, crc32 = filecrc32,
+ crc32valid = filecrc32 == crc32})
+ ,rem2)
-- | Read the file's compressed data, returning
-- (Decompressed, Calculated CRC32, Remainder)
diff --git a/testsrc/GZiptest.hs b/testsrc/GZiptest.hs
index 770c81b..cd89fb4 100644
--- a/testsrc/GZiptest.hs
+++ b/testsrc/GZiptest.hs
@@ -28,13 +28,23 @@ mf fn exp conf = TestLabel fn $ TestCase $
do c <- readFile ("testsrc/gzfiles/" ++ fn)
assertEqual "" exp (conf c)
+{-
+import MissingH.FileArchive.GZip
+import System.IO
+import MissingH.Either
+
+main = do
+ c <- hGetContents stdin
+ let x = snd . forceEither . read_header $ c
+ putStr x
+
test_bunches =
let f fn exp conv = mf fn exp (conv . snd . forceEither . read_header)
f2 c = let fn = "t/z" ++ (show c) ++ ".gz" in
f fn c (length . inflate_string)
in
map f2 [0..1000]
-
+-}
test_inflate =
let f fn exp conv = mf fn exp (conv . snd . forceEither . read_header) in
[
@@ -69,7 +79,7 @@ test_gunzip =
tests = TestList [TestLabel "inflate" (TestList test_inflate),
TestLabel "header" (TestList test_header),
- TestLabel "bunches" (TestList test_bunches),
+-- TestLabel "bunches" (TestList test_bunches),
TestLabel "gunzip" (TestList test_gunzip)
]
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list