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


The following commit has been merged in the master branch:
commit 49b548dde4f32d13dbff55bd6a02437744dac547
Author: John Goerzen <jgoerzen at complete.org>
Date:   Sun Dec 5 00:07:49 2004 +0100

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

diff --git a/ChangeLog b/ChangeLog
index 3ee31d5..6a1e0f0 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 17:07:49 GMT	John Goerzen <jgoerzen at complete.org>	patch-43
+
+    Summary:
+      Checkpointing
+    Revision:
+      missingh--head--0.7--patch-43
+
+
+    modified files:
+     ChangeLog Makefile libsrc/MissingH/FileArchive/GZip.hs
+     testsrc/GZiptest.hs
+
+
 2004-12-04 16:19:30 GMT	John Goerzen <jgoerzen at complete.org>	patch-42
 
     Summary:
diff --git a/Makefile b/Makefile
index 94fcfea..ea863ef 100644
--- a/Makefile
+++ b/Makefile
@@ -33,7 +33,7 @@ libmissingH.a: $(OBJS)
 	ar q libmissingH.a $(OBJS)
 
 %.o: %.hs
-	ghc -fallow-overlapping-instances -fallow-undecidable-instances -fglasgow-exts -ilibsrc --make `echo $< | sed -e s,libsrc/,, -e s,.hs$$,, -e s,/,.,g`
+	ghc -O -fallow-overlapping-instances -fallow-undecidable-instances -fglasgow-exts -ilibsrc --make `echo $< | sed -e s,libsrc/,, -e s,.hs$$,, -e s,/,.,g`
 
 %.o: %.lhs
 	ghc -fallow-overlapping-instances -fallow-undecidable-instances -fglasgow-exts -ilibsrc --make `echo $< | sed -e s,libsrc/,, -e s,.lhs$$,, -e s,/,.,g`
diff --git a/libsrc/MissingH/FileArchive/GZip.hs b/libsrc/MissingH/FileArchive/GZip.hs
index c4e7455..99e51e5 100644
--- a/libsrc/MissingH/FileArchive/GZip.hs
+++ b/libsrc/MissingH/FileArchive/GZip.hs
@@ -33,11 +33,16 @@ Copyright (c) 2004 John Goerzen, jgoerzen\@complete.org
 The GZip format is described in RFC1952.
 -}
 module MissingH.FileArchive.GZip (
+                                  -- * GZip Files
+                                  -- $gzipfiles
+                                  -- * Types
+                                  Header(..), Section, GZipError, Footer(..),
+                                  -- * Whole-File Processing
                                   decompress,
+                                  read_sections,
+                                  -- * Section Processing
                                   read_header,
-                                  Header(..), Section, GZipError, Footer(..),
-                                  read_section,
-                                  read_sections
+                                  read_section
                                  )
 where
 
@@ -62,30 +67,38 @@ fFEXTRA = 4::Int
 fFNAME = 8::Int
 fFCOMMENT = 16::Int
 
+{- | The data structure representing the GZip header.  This occurs
+at the beginning of each 'Section' on disk. -}
 data Header = Header {
-                      method :: Int,
+                      method :: Int,    -- ^ Compression method.  Only 8 is defined at present.
                       flags :: Int,
                       extra :: Maybe String,
                       filename :: Maybe String,
                       comment :: Maybe String,
-                      mtime :: Word32,
-                      xfl :: Int,
-                      os :: Int
+                      mtime :: Word32,  -- ^ Modification time of the original file
+                      xfl :: Int,       -- ^ Extra flags
+                      os :: Int         -- ^ Creating operating system
                      } deriving (Eq, Show)
 
+{- | Stored on-disk at the end of each section. -}
 data Footer = Footer {
-                      size :: Word32,
-                      crc32 :: Word32,
-                      crc32valid :: Bool}
+                      size :: Word32,   -- ^ The size of the original, decompressed data
+                      crc32 :: Word32,  -- ^ The stored GZip CRC-32 of the original, decompressed data
+                      crc32valid :: Bool -- ^ Whether or not the stored CRC-32 matches the calculated CRC-32 of the data
+                     }
 
+{- | A section represents a compressed component in a GZip file.
+Every GZip file has at least one. -}
 type Section = (Header, String, Footer)
 
 split1 :: String -> (Char, String)
 split1 s = (head s, tail s)
 
-{- | Read a GZip file.
--}
+{- | Read a GZip file, decompressing all sections that are found.
 
+Returns a decompresed data stream and a Bool indicating whether or not
+all CRC32 values were successfully verified.
+-}
 decompress :: String -> Either GZipError (String, Bool)
 {-
 decompress s = 
@@ -215,3 +228,37 @@ read_header s =
                       mtime = mtime,
                       xfl = xfl,
                       os = os}, rem8)
+
+----------------------------------------------------------------------
+-- Documentation
+----------------------------------------------------------------------
+
+{- $gzipfiles
+
+GZip files contain one or more 'Section's.  Each 'Section', on disk, begins
+with a GZip 'Header', then stores the compressed data itself, and finally
+stores a GZip 'Footer'.
+
+The 'Header' identifies the file as a GZip file, records the original
+modification date and time, and, in some cases, also records the original
+filename and comments.
+
+The 'Footer' contains a GZip CRC32 checksum over the decompressed data as
+well as a 32-bit length of the decompressed data.  The module
+'MissingH.Checksum.CRC32.GZip' is used to validate stored CRC32 values.
+
+The vast majority of GZip files contain only one 'Section'.  Standard tools
+that work with GZip files create single-section files by default.
+
+Multi-section files can be created by simply concatenating two existing
+GZip files together.  The standard gunzip and zcat tools will simply
+concatenate the decompressed data when reading these files back.  The
+'decompress' function in this module will do the same.
+
+When reading data from this module, please use caution regarding how you access
+it.  For instance, if you are wanting to write the decompressed stream
+to disk and validate its CRC32 value, you could use the 'decompress'
+function.  However, you should process the entire stream before you check
+the value of the Bool it returns.  Otherwise, you will force Haskell to buffer
+the entire file in memory just so it can check the CRC32.
+-}
diff --git a/testsrc/GZiptest.hs b/testsrc/GZiptest.hs
index 8679fc2..66bb5c1 100644
--- a/testsrc/GZiptest.hs
+++ b/testsrc/GZiptest.hs
@@ -53,8 +53,9 @@ test_inflate =
         ,f "t1.gz" ("Test 1",
                     "\x19\xf8\x27\x99\x06\x00\x00\x00") inflate_string_remainder
         ,f "empty.gz" "" inflate_string
-        ,f "zeros.gz" 10485760 (length . inflate_string)
-        --,f "zeros.gz" (replicate (10 * 1048576) '\0') inflate_string
+        --,f "zeros.gz" 10485760 (length . inflate_string)
+        -- BAD BAD ,f "zeros.gz" (replicate (10 * 1048576) '\0') inflate_string
+        ,f "zeros.gz" True (\x -> (replicate 10485760 '\0') == inflate_string x)
         ]
 
 test_header =

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list