diff --git a/src/CabalFmt/Fields/SourceFiles.hs b/src/CabalFmt/Fields/SourceFiles.hs index a387640..cf0f005 100644 --- a/src/CabalFmt/Fields/SourceFiles.hs +++ b/src/CabalFmt/Fields/SourceFiles.hs @@ -7,7 +7,9 @@ module CabalFmt.Fields.SourceFiles ( fileFields, ) where -import System.FilePath.Posix (splitDirectories) +-- Make sure we explicitly use Posix's splitDirectories +-- when parsing glob syntax since only `/` is valid, and not '\\' +import qualified System.FilePath.Posix as Posix (splitDirectories) import qualified Distribution.FieldGrammar as C import qualified Distribution.Fields as C @@ -46,7 +48,7 @@ pretty :: [FilePath] -> PP.Doc pretty = PP.vcat . map C.showFilePath . nub - . sortBy (cmp `on` map strToLower . splitDirectories) + . sortBy (cmp `on` map strToLower . Posix.splitDirectories) where cmp a b = case dropCommonPrefix a b of ([], []) -> EQ diff --git a/src/CabalFmt/Glob.hs b/src/CabalFmt/Glob.hs index d368991..e8d04f1 100644 --- a/src/CabalFmt/Glob.hs +++ b/src/CabalFmt/Glob.hs @@ -2,7 +2,9 @@ module CabalFmt.Glob where import Data.List (isInfixOf) import Data.List.NonEmpty (NonEmpty (..)) -import System.FilePath.Posix (splitDirectories) +-- Make sure we explicitly use Posix's splitDirectories +-- when parsing glob syntax since only `/` is valid, and not '\\' +import qualified System.FilePath.Posix as Posix (splitDirectories) import CabalFmt.Prelude @@ -27,7 +29,7 @@ data GlobChar -- [False,False,True,True] -- match :: Glob -> FilePath -> Bool -match (Glob g1 gs0) fp = go0 (splitDirectories fp) where +match (Glob g1 gs0) fp = go0 (Posix.splitDirectories fp) where go0 [] = False go0 (p:ps) = if p == g1 then go ps gs0 else False @@ -47,7 +49,7 @@ match (Glob g1 gs0) fp = go0 (splitDirectories fp) where matches (x:xs) (GlobChar c : cs) = if x == c then matches xs cs else False parseGlob :: String -> Either String Glob -parseGlob input = case splitDirectories input of +parseGlob input = case Posix.splitDirectories input of [] -> Left "empty path" (x:xs) -> do p <- parseFirstPiece x