Gentoo Archives: gentoo-commits

From: "Mark Wright (gienah)" <gienah@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-haskell/zip-archive/files: zip-archive-0.1.2.1-binary-0.6.patch
Date: Sat, 24 Nov 2012 04:42:21
Message-Id: 20121124044204.CBB6A20C65@flycatcher.gentoo.org
1 gienah 12/11/24 04:42:04
2
3 Added: zip-archive-0.1.2.1-binary-0.6.patch
4 Log:
5 Bump zip-archive to 0.1.2.1
6
7 (Portage version: 2.1.11.31/cvs/Linux x86_64, signed Manifest commit with key 618E971F)
8
9 Revision Changes Path
10 1.1 dev-haskell/zip-archive/files/zip-archive-0.1.2.1-binary-0.6.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-haskell/zip-archive/files/zip-archive-0.1.2.1-binary-0.6.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-haskell/zip-archive/files/zip-archive-0.1.2.1-binary-0.6.patch?rev=1.1&content-type=text/plain
14
15 Index: zip-archive-0.1.2.1-binary-0.6.patch
16 ===================================================================
17 Patch is in experimental state.
18 Hasn't sent upstream. Maybe binary package is
19 a better place to get lookAhead{,M} back
20 to lessen code uglification.
21
22 diff --git a/Codec/Archive/Zip.hs b/Codec/Archive/Zip.hs
23 index 4ad717b..e471786 100644
24 --- a/Codec/Archive/Zip.hs
25 +++ b/Codec/Archive/Zip.hs
26 @@ -61,7 +61,9 @@ import Data.Time.Clock.POSIX ( utcTimeToPOSIXSeconds )
27 #endif
28 import Data.Bits ( shiftL, shiftR, (.&.) )
29 import Data.Binary
30 +import Control.Applicative ((<|>))
31 import Data.Binary.Get
32 +import Data.Maybe
33 import Data.Binary.Put
34 import Data.List ( nub, find )
35 import Text.Printf
36 @@ -88,6 +90,22 @@ import qualified Codec.Compression.Zlib.Raw as Zlib
37
38 ------------------------------------------------------------------------
39
40 +lookAheadM :: Get (Maybe a) -> Get (Maybe a)
41 +lookAheadM gma =
42 + (do ma <- gma
43 + case ma of
44 + Nothing -> fail "lookAheadM: input not met"
45 + _ -> return ma
46 + ) <|> return Nothing
47 +
48 +lookAndCheck :: (a -> Bool) -> Get a -> Get (Maybe a)
49 +lookAndCheck p gma =
50 + (do ma <- gma
51 + if p ma
52 + then return (Just ma)
53 + else fail "lookAndCheck: input not met"
54 + ) <|> return Nothing
55 +
56 -- | Structured representation of a zip archive, including directory
57 -- information and contents (in lazy bytestrings).
58 data Archive = Archive
59 @@ -492,12 +510,11 @@ localFileSize f =
60
61 getLocalFile :: Get (Maybe (Word32, B.ByteString))
62 getLocalFile = do
63 - sig <- lookAhead getWord32le
64 - if sig /= 0x04034b50
65 + offset <- bytesRead
66 + sig <- lookAndCheck (== 0x04034b50) getWord32le
67 + if isNothing sig
68 then return Nothing
69 else do
70 - offset <- bytesRead
71 - skip 4 -- signature
72 skip 2 -- version
73 bitflag <- getWord16le
74 skip 2 -- compressionMethod
75 @@ -520,11 +537,10 @@ getLocalFile = do
76 -- record has signature 0x08074b50; this is not required
77 -- by the specification but is common.
78 do raw <- many $ do
79 - s <- lookAhead getWord32le
80 - if s == 0x08074b50
81 + s <- lookAndCheck (== 0x08074b50) getWord32le
82 + if isJust s
83 then return Nothing
84 else liftM Just getWord8
85 - skip 4 -- signature
86 skip 4 -- crc32
87 cs <- getWord32le -- compressed size
88 skip 4 -- uncompressed size
89 @@ -581,11 +597,10 @@ putLocalFile f = do
90 getFileHeader :: M.Map Word32 B.ByteString -- ^ map of (offset, content) pairs returned by getLocalFile
91 -> Get (Maybe Entry)
92 getFileHeader locals = do
93 - sig <- lookAhead getWord32le
94 - if sig /= 0x02014b50
95 + sig <- lookAndCheck (== 0x02014b50) getWord32le
96 + if isNothing sig
97 then return Nothing
98 else do
99 - skip 4 -- skip past signature
100 skip 2 -- version made by
101 versionNeededToExtract <- getWord8
102 skip 1 -- upper byte indicates OS part of "version needed to extract"
103 diff --git a/zip-archive.cabal b/zip-archive.cabal
104 index 435514c..cbc8da8 100644
105 --- a/zip-archive.cabal
106 +++ b/zip-archive.cabal
107 @@ -29,7 +29,7 @@ Library
108 Build-depends: base >= 3 && < 5, pretty, containers
109 else
110 Build-depends: base < 3
111 - Build-depends: binary < 0.6, zlib, filepath, bytestring >= 0.9.0, array, mtl, utf8-string >= 0.3.1, old-time, digest >= 0.0.0.1, directory, time
112 + Build-depends: binary >= 0.6, zlib, filepath, bytestring >= 0.9.0, array, mtl, utf8-string >= 0.3.1, old-time, digest >= 0.0.0.1, directory, time
113 Exposed-modules: Codec.Archive.Zip
114 Default-Language: Haskell98
115 Hs-Source-Dirs: .