Merge branch 'master' into v8
This commit is contained in:
commit
2cea674d1e
44 changed files with 665 additions and 140 deletions
|
@ -8,7 +8,9 @@
|
|||
{-# LANGUAGE CPP #-}
|
||||
|
||||
module Utility.Daemon (
|
||||
#ifndef mingw32_HOST_OS
|
||||
daemonize,
|
||||
#endif
|
||||
foreground,
|
||||
checkDaemon,
|
||||
stopDaemon,
|
||||
|
|
|
@ -43,7 +43,6 @@ import qualified Data.ByteString.Lazy as L
|
|||
import qualified Data.ByteString.UTF8 as S8
|
||||
import qualified Data.ByteString.Lazy.UTF8 as L8
|
||||
#endif
|
||||
import System.FilePath.ByteString (RawFilePath, encodeFilePath, decodeFilePath)
|
||||
|
||||
import Utility.Exception
|
||||
import Utility.Split
|
||||
|
@ -172,11 +171,21 @@ encodeBL' = L.pack . decodeW8
|
|||
encodeBL' = L8.fromString
|
||||
#endif
|
||||
|
||||
fromRawFilePath :: RawFilePath -> FilePath
|
||||
fromRawFilePath = decodeFilePath
|
||||
{- Recent versions of the unix package have this alias; defined here
|
||||
- for backwards compatibility. -}
|
||||
type RawFilePath = S.ByteString
|
||||
|
||||
{- Note that the RawFilePath is assumed to never contain NUL,
|
||||
- since filename's don't. This should only be used with actual
|
||||
- RawFilePaths not arbitrary ByteString that may contain NUL. -}
|
||||
fromRawFilePath :: RawFilePath -> FilePath
|
||||
fromRawFilePath = decodeBS'
|
||||
|
||||
{- Note that the FilePath is assumed to never contain NUL,
|
||||
- since filename's don't. This should only be used with actual FilePaths
|
||||
- not arbitrary String that may contain NUL. -}
|
||||
toRawFilePath :: FilePath -> RawFilePath
|
||||
toRawFilePath = encodeFilePath
|
||||
toRawFilePath = encodeBS'
|
||||
|
||||
{- Converts a [Word8] to a FilePath, encoding using the filesystem encoding.
|
||||
-
|
||||
|
|
|
@ -15,7 +15,7 @@ module Utility.Format (
|
|||
) where
|
||||
|
||||
import Text.Printf (printf)
|
||||
import Data.Char (isAlphaNum, isOctDigit, isHexDigit, isSpace, chr, ord)
|
||||
import Data.Char (isAlphaNum, isOctDigit, isHexDigit, isSpace, chr, ord, isAscii)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Data.Word (Word8)
|
||||
import Data.List (isPrefixOf)
|
||||
|
@ -176,12 +176,12 @@ encode_c' p = concatMap echar
|
|||
{- For quickcheck.
|
||||
-
|
||||
- Encoding and then decoding roundtrips only when
|
||||
- the string does not contain high unicode, because eg,
|
||||
- both "\12345" and "\227\128\185" are encoded to "\343\200\271".
|
||||
- the string is ascii because eg, both "\12345" and
|
||||
- "\227\128\185" are encoded to "\343\200\271".
|
||||
-
|
||||
- This property papers over the problem, by only testing chars < 256.
|
||||
- This property papers over the problem, by only testing ascii.
|
||||
-}
|
||||
prop_encode_c_decode_c_roundtrip :: String -> Bool
|
||||
prop_encode_c_decode_c_roundtrip s = s' == decode_c (encode_c s')
|
||||
where
|
||||
s' = filter (\c -> ord c < 256) s
|
||||
s' = filter isAscii s
|
||||
|
|
|
@ -31,6 +31,7 @@ doesPathExist = fileExist
|
|||
|
||||
#else
|
||||
import qualified Data.ByteString as B
|
||||
import System.PosixCompat (FileStatus)
|
||||
import qualified System.PosixCompat as P
|
||||
import qualified System.Directory as D
|
||||
import Utility.FileSystemEncoding
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue