Skip to content

Commit 9c985e5

Browse files
committed
Require text>=2.0.2 to eliminate CPP
1 parent e0085a5 commit 9c985e5

File tree

3 files changed

+3
-52
lines changed

3 files changed

+3
-52
lines changed

Cabal-syntax/Cabal-syntax.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ library
3939
, mtl >= 2.1 && < 2.4
4040
, parsec >= 3.1.13.0 && < 3.2
4141
, pretty >= 1.1.1 && < 1.2
42-
, text (>= 1.2.3.0 && < 1.3) || (>= 2.0 && < 2.2)
42+
, text >= 2.0.2 && < 2.2
4343
, time >= 1.4.0.1 && < 1.16
4444
-- transformers-0.4.0.0 doesn't have record syntax e.g. for Identity
4545
-- See also https://github.com/ekmett/transformers-compat/issues/35

Cabal-syntax/src/Distribution/Parsec/FieldLineStream.hs

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,8 @@ import Distribution.Utils.Generic (toUTF8BS)
1818
import Prelude ()
1919

2020
import qualified Data.ByteString as BS
21-
import qualified Text.Parsec as Parsec
22-
23-
#if MIN_VERSION_text(2,0,0)
2421
import Data.Text.Internal.Encoding.Utf8
25-
#else
26-
import Data.Bits
27-
#endif
22+
import qualified Text.Parsec as Parsec
2823

2924
-- | This is essentially a lazy bytestring, but chunks are glued with newline @\'\\n\'@.
3025
data FieldLineStream
@@ -53,7 +48,6 @@ instance Monad m => Parsec.Stream FieldLineStream m Char where
5348
Nothing -> Just ('\n', s)
5449
Just (c, bs') -> Just (unconsChar c bs' (\bs'' -> FLSCons bs'' s) s)
5550

56-
#if MIN_VERSION_text(2,0,0)
5751
unconsChar :: forall a. Word8 -> ByteString -> (ByteString -> a) -> a -> (Char, a)
5852
unconsChar c0 bs0 f next = go (utf8DecodeStart c0) bs0
5953
where
@@ -63,49 +57,6 @@ unconsChar c0 bs0 f next = go (utf8DecodeStart c0) bs0
6357
Incomplete state codePoint -> case BS.uncons bs of
6458
Nothing -> (replacementChar, next)
6559
Just (w, bs') -> go (utf8DecodeContinue w state codePoint) bs'
66-
#else
67-
-- Based on implementation 'decodeStringUtf8'
68-
unconsChar :: forall a. Word8 -> ByteString -> (ByteString -> a) -> a -> (Char, a)
69-
unconsChar c0 bs0 f next
70-
| c0 <= 0x7F = (chr (fromIntegral c0), f bs0)
71-
| c0 <= 0xBF = (replacementChar, f bs0)
72-
| c0 <= 0xDF = twoBytes
73-
| c0 <= 0xEF = moreBytes 3 0x800 bs0 (fromIntegral $ c0 .&. 0xF)
74-
| c0 <= 0xF7 = moreBytes 4 0x10000 bs0 (fromIntegral $ c0 .&. 0x7)
75-
| c0 <= 0xFB = moreBytes 5 0x200000 bs0 (fromIntegral $ c0 .&. 0x3)
76-
| c0 <= 0xFD = moreBytes 6 0x4000000 bs0 (fromIntegral $ c0 .&. 0x1)
77-
| otherwise = error $ "not implemented " ++ show c0
78-
where
79-
twoBytes = case BS.uncons bs0 of
80-
Nothing -> (replacementChar, next)
81-
Just (c1, bs1)
82-
| c1 .&. 0xC0 == 0x80 ->
83-
if d >= 0x80
84-
then (chr d, f bs1)
85-
else (replacementChar, f bs1)
86-
| otherwise -> (replacementChar, f bs1)
87-
where
88-
d = (fromIntegral (c0 .&. 0x1F) `shiftL` 6) .|. fromIntegral (c1 .&. 0x3F)
89-
90-
moreBytes :: Int -> Int -> ByteString -> Int -> (Char, a)
91-
moreBytes 1 overlong bs' acc
92-
| overlong <= acc
93-
, acc <= 0x10FFFF
94-
, acc < 0xD800 || 0xDFFF < acc =
95-
(chr acc, f bs')
96-
| otherwise =
97-
(replacementChar, f bs')
98-
moreBytes byteCount overlong bs' acc = case BS.uncons bs' of
99-
Nothing -> (replacementChar, f bs')
100-
Just (cn, bs1)
101-
| cn .&. 0xC0 == 0x80 ->
102-
moreBytes
103-
(byteCount - 1)
104-
overlong
105-
bs1
106-
((acc `shiftL` 6) .|. fromIntegral cn .&. 0x3F)
107-
| otherwise -> (replacementChar, f bs1)
108-
#endif
10960

11061
replacementChar :: Char
11162
replacementChar = '\xfffd'

bootstrap/linux-9.2.8.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
},
7171
{
7272
"package": "text",
73-
"version": "1.2.5.0"
73+
"version": "2.0.2"
7474
},
7575
{
7676
"package": "parsec",

0 commit comments

Comments
 (0)