[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:55 UTC 2010


The following commit has been merged in the master branch:
commit 53e45701572b1d0e0fbb6b7ffe68073fbfece60f
Author: John Goerzen <jgoerzen at complete.org>
Date:   Sat Dec 4 09:32:59 2004 +0100

    Checkpointing
    
    Keywords:
    
    
    (jgoerzen at complete.org--projects/missingh--head--0.7--patch-34)

diff --git a/ChangeLog b/ChangeLog
index b8dd2d6..15b1bb2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,22 @@
 # arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.7
 #
 
+2004-12-04 02:32:59 GMT	John Goerzen <jgoerzen at complete.org>	patch-34
+
+    Summary:
+      Checkpointing
+    Revision:
+      missingh--head--0.7--patch-34
+
+
+    new files:
+     testsrc/gzfiles/.arch-ids/empty.gz.id testsrc/gzfiles/empty.gz
+
+    modified files:
+     ChangeLog libsrc/MissingH/FileArchive/GZip.hs
+     testsrc/CRC32GZIPtest.hs testsrc/GZiptest.hs
+
+
 2004-12-04 02:24:38 GMT	John Goerzen <jgoerzen at complete.org>	patch-33
 
     Summary:
diff --git a/libsrc/MissingH/FileArchive/GZip.hs b/libsrc/MissingH/FileArchive/GZip.hs
index e5ca63b..c473fd3 100644
--- a/libsrc/MissingH/FileArchive/GZip.hs
+++ b/libsrc/MissingH/FileArchive/GZip.hs
@@ -20,7 +20,8 @@ The GZip format is described in RFC1952
 
 module MissingH.FileArchive.GZip (
                                   decompress,
-                                  read_header
+                                  read_header,
+                                  Header(..)
                                  )
 where
 
@@ -80,6 +81,9 @@ read_sections s = do x <- read_section s
                                                     next <- read_sections remain
                                                     return $ (head, this) : 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_section s =
@@ -88,8 +92,7 @@ read_section s =
            let (decompressed, crc32, remainder) = read_data headerrem
            let (crc32str, rem) = splitAt 4 remainder
            let (sizestr, rem2) = splitAt 4 rem
-           let filecrc32 = fromBytes $
-                           map (fromIntegral . ord) $ reverse crc32str
+           let filecrc32 = parseword crc32str
            
            if filecrc32 == crc32 
               then return $ (fst x, decompressed, rem2)
@@ -131,6 +134,8 @@ read_header s =
           else ok
        let (flag_S, rem3) = split1 rem2
        let flag = ord flag_S
+       --let (mtimea, rem3a) = splitAt 4 rem2
+       --let mtime = 
        -- skip modtime (4), extraflag (1), and os (1)
        let rem4 = drop 6 rem3
        
diff --git a/testsrc/CRC32GZIPtest.hs b/testsrc/CRC32GZIPtest.hs
index f08c4f9..c562bf1 100644
--- a/testsrc/CRC32GZIPtest.hs
+++ b/testsrc/CRC32GZIPtest.hs
@@ -23,6 +23,7 @@ import MissingH.Checksum.CRC32.GZip
 test_crcgzip =
     let f msg inp exp = TestLabel msg $ TestCase $ assertEqual "" exp (calc_crc32 inp) in
         [f "Simple" "Test 1" 0x9927f819
+        ,f "Empty" "" 0x0
          --f "Empty" "" 4294967295,
          --f "1" "1" 433426081,
          --f "some numbers" "153141341309874102987412" 2083856642,
diff --git a/testsrc/GZiptest.hs b/testsrc/GZiptest.hs
index da8053b..be5252a 100644
--- a/testsrc/GZiptest.hs
+++ b/testsrc/GZiptest.hs
@@ -35,6 +35,16 @@ test_inflate =
                     "\x19\xf8\x27\x99\x06\x00\x00\x00") inflate_string_remainder
         ]
 
+test_header =
+    let f fn exp = mf fn exp (fst . forceEither . read_header)
+        in
+        [
+         f "t1.gz" Header {method = 8, flags = 0, extra = Nothing,
+                            filename = Nothing, comment = Nothing}
+        ,f "empty.gz" Header {method = 8, flags = 8, extra = Nothing,
+                              filename = Just "empty", 
+                              comment = Nothing}
+        ]
 
 test_gunzip =
     let f fn exp = mf fn (Right exp) decompress
@@ -44,6 +54,7 @@ test_gunzip =
         ]
 
 tests = TestList [TestLabel "inflate" (TestList test_inflate),
+                  TestLabel "header" (TestList test_header),
                   TestLabel "gunzip" (TestList test_gunzip)
 
                  ]
diff --git a/testsrc/gzfiles/empty.gz b/testsrc/gzfiles/empty.gz
new file mode 100644
index 0000000..0782b98
Binary files /dev/null and b/testsrc/gzfiles/empty.gz differ

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list