Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Cabal
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Glasgow Haskell Compiler
Packages
Cabal
Commits
76ce99ad
Commit
76ce99ad
authored
5 years ago
by
Oleg Grenrus
Browse files
Options
Downloads
Patches
Plain Diff
Add Distribution.Compat.MD5
parent
12a49040
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Cabal/Cabal.cabal
+1
-0
1 addition, 0 deletions
Cabal/Cabal.cabal
Cabal/Distribution/Compat/MD5.hs
+50
-0
50 additions, 0 deletions
Cabal/Distribution/Compat/MD5.hs
Cabal/Distribution/PackageDescription/Quirks.hs
+6
-14
6 additions, 14 deletions
Cabal/Distribution/PackageDescription/Quirks.hs
with
57 additions
and
14 deletions
Cabal/Cabal.cabal
+
1
−
0
View file @
76ce99ad
...
...
@@ -531,6 +531,7 @@ library
Distribution.Utils.Base62
Distribution.Compat.CopyFile
Distribution.Compat.GetShortPathName
Distribution.Compat.MD5
Distribution.Compat.MonadFail
Distribution.Compat.Prelude
Distribution.Compat.SnocList
...
...
This diff is collapsed.
Click to expand it.
Cabal/Distribution/Compat/MD5.hs
0 → 100644
+
50
−
0
View file @
76ce99ad
module
Distribution.Compat.MD5
(
MD5
,
showMD5
,
md5
,
-- * Binary
binaryPutMD5
,
binaryGetMD5
,
)
where
import
Data.Binary
(
Get
,
Put
)
import
Data.Binary.Get
(
getWord64le
)
import
Data.Binary.Put
(
putWord64le
)
import
Foreign.Ptr
(
castPtr
)
import
GHC.Fingerprint
(
Fingerprint
(
..
),
fingerprintData
)
import
Numeric
(
showHex
)
import
System.IO.Unsafe
(
unsafeDupablePerformIO
)
import
qualified
Data.ByteString
as
BS
import
qualified
Data.ByteString.Unsafe
as
BS
type
MD5
=
Fingerprint
-- | Show 'MD5' in human readable form
--
-- >>> showMD5 (Fingerprint 123 456)
-- "000000000000007b00000000000001c8"
--
-- >>> showMD5 $ md5 $ BS.pack [0..127]
-- "37eff01866ba3f538421b30b7cbefcac"
--
showMD5
::
MD5
->
String
showMD5
(
Fingerprint
a
b
)
=
pad
a'
++
pad
b'
where
a'
=
showHex
a
""
b'
=
showHex
b
""
pad
s
=
replicate
(
16
-
length
s
)
'0'
++
s
md5
::
BS
.
ByteString
->
MD5
md5
bs
=
unsafeDupablePerformIO
$
BS
.
unsafeUseAsCStringLen
bs
$
\
(
ptr
,
len
)
->
fingerprintData
(
castPtr
ptr
)
len
binaryPutMD5
::
MD5
->
Put
binaryPutMD5
(
Fingerprint
a
b
)
=
do
putWord64le
a
putWord64le
b
binaryGetMD5
::
Get
MD5
binaryGetMD5
=
do
a
<-
getWord64le
b
<-
getWord64le
return
(
Fingerprint
a
b
)
This diff is collapsed.
Click to expand it.
Cabal/Distribution/PackageDescription/Quirks.hs
+
6
−
14
View file @
76ce99ad
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
-- |
--
-- @since 2.2.0.0
module
Distribution.PackageDescription.Quirks
(
patchQuirks
)
where
import
Prelude
()
import
Distribution.Compat.Prelude
import
GHC.Fingerprint
(
Fingerprint
(
..
),
fingerprintData
)
import
Foreign.Ptr
(
castPtr
)
import
System.IO.Unsafe
(
unsafeDupablePerformIO
)
import
Distribution.Compat.MD5
import
Distribution.Compat.Prelude
import
GHC.Fingerprint
(
Fingerprint
(
..
))
import
Prelude
()
import
qualified
Data.ByteString
as
BS
import
qualified
Data.ByteString.Unsafe
as
BS
import
qualified
Data.Map
as
Map
import
qualified
Data.Map
as
Map
-- | Patch legacy @.cabal@ file contents to allow parsec parser to accept
-- all of Hackage.
...
...
@@ -30,13 +28,7 @@ patchQuirks bs = case Map.lookup (BS.take 256 bs, md5 bs) patches of
where
output
=
f
bs
md5
::
BS
.
ByteString
->
Fingerprint
md5
bs
=
unsafeDupablePerformIO
$
BS
.
unsafeUseAsCStringLen
bs
$
\
(
ptr
,
len
)
->
fingerprintData
(
castPtr
ptr
)
len
-- | 'patches' contains first 256 bytes, pre- and post-fingerprints and a patch function.
--
--
patches
::
Map
.
Map
(
BS
.
ByteString
,
Fingerprint
)
(
Fingerprint
,
BS
.
ByteString
->
BS
.
ByteString
)
patches
=
Map
.
fromList
-- http://hackage.haskell.org/package/unicode-transforms-0.3.3
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment