-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #296 from phadej/bytestring-0.11
bytestring-0.11
- Loading branch information
Showing
10 changed files
with
183 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- this project doesn't have local 'text' package, | ||
-- so tests build faster. | ||
|
||
packages: tests | ||
tests: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
runtest() { | ||
HC=$1 | ||
shift | ||
|
||
# EDIT last line to pass arguments | ||
|
||
cabal run text-tests:test:tests \ | ||
--project-file=cabal.tests.project \ | ||
--builddir="dist-newstyle/$HC" \ | ||
--with-compiler="$HC" \ | ||
-- "$@" | ||
} | ||
|
||
runtest ghc-8.10.2 "$@" | ||
runtest ghc-8.8.4 "$@" | ||
runtest ghc-8.6.5 "$@" | ||
runtest ghc-8.4.4 "$@" | ||
runtest ghc-8.2.2 "$@" | ||
runtest ghc-8.0.2 "$@" | ||
|
||
runtest ghc-7.10.3 "$@" | ||
runtest ghc-7.8.4 "$@" | ||
runtest ghc-7.6.3 "$@" | ||
runtest ghc-7.4.2 "$@" | ||
runtest ghc-7.2.2 "$@" | ||
runtest ghc-7.0.4 "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{-# LANGUAGE BangPatterns #-} | ||
{-# LANGUAGE CPP #-} | ||
{-# LANGUAGE MagicHash #-} | ||
module Data.Text.Internal.ByteStringCompat (mkBS, withBS) where | ||
|
||
import Data.ByteString.Internal (ByteString (..)) | ||
import Data.Word (Word8) | ||
import Foreign.ForeignPtr (ForeignPtr) | ||
|
||
#if !MIN_VERSION_bytestring(0,11,0) | ||
#if MIN_VERSION_base(4,10,0) | ||
import GHC.ForeignPtr (plusForeignPtr) | ||
#else | ||
import GHC.ForeignPtr (ForeignPtr(ForeignPtr)) | ||
import GHC.Types (Int (..)) | ||
import GHC.Prim (plusAddr#) | ||
#endif | ||
#endif | ||
|
||
mkBS :: ForeignPtr Word8 -> Int -> ByteString | ||
#if MIN_VERSION_bytestring(0,11,0) | ||
mkBS dfp n = BS dfp n | ||
#else | ||
mkBS dfp n = PS dfp 0 n | ||
#endif | ||
{-# INLINE mkBS #-} | ||
|
||
withBS :: ByteString -> (ForeignPtr Word8 -> Int -> r) -> r | ||
#if MIN_VERSION_bytestring(0,11,0) | ||
withBS (BS !sfp !slen) kont = kont sfp slen | ||
#else | ||
withBS (PS !sfp !soff !slen) kont = kont (plusForeignPtr sfp soff) slen | ||
#endif | ||
{-# INLINE withBS #-} | ||
|
||
#if !MIN_VERSION_bytestring(0,11,0) | ||
#if !MIN_VERSION_base(4,10,0) | ||
-- |Advances the given address by the given offset in bytes. | ||
-- | ||
-- The new 'ForeignPtr' shares the finalizer of the original, | ||
-- equivalent from a finalization standpoint to just creating another | ||
-- reference to the original. That is, the finalizer will not be | ||
-- called before the new 'ForeignPtr' is unreachable, nor will it be | ||
-- called an additional time due to this call, and the finalizer will | ||
-- be called with the same address that it would have had this call | ||
-- not happened, *not* the new address. | ||
plusForeignPtr :: ForeignPtr a -> Int -> ForeignPtr b | ||
plusForeignPtr (ForeignPtr addr guts) (I# offset) = ForeignPtr (plusAddr# addr offset) guts | ||
{-# INLINE [0] plusForeignPtr #-} | ||
{-# RULES | ||
"ByteString plusForeignPtr/0" forall fp . | ||
plusForeignPtr fp 0 = fp | ||
#-} | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters