Skip to content

Commit

Permalink
Normalize to NFC before comparison (fix #1810)
Browse files Browse the repository at this point in the history
The filename gets normalized to NFD on OS X causing spurious failures.

Let's normalize both sides to NFC in case the Cabal file is in some
other normalization for any reason.

This is a slight hack.
  • Loading branch information
Blaisorblade committed Aug 2, 2016
1 parent d784870 commit 7ec9dd8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Stack/Solver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ import qualified System.Directory as D
import qualified System.FilePath as FP
import System.Process.Read

import qualified Data.Text.Normalize as T ( normalize )
import Data.Unicode.Types ( NormalizationMode(NFC) )

data ConstraintType = Constraint | Preference deriving (Eq)
type ConstraintSpec = Map PackageName (Version, Map FlagName Bool)
Expand Down Expand Up @@ -560,8 +562,10 @@ cabalPackagesCheck cabalfps noPkgMsg dupErrMsg = do
-- Just the latter check is enough to cover both the cases

let packages = zip cabalfps gpds
-- XXX taken from https://github.com/ppelleti/normalization-insensitive, see #1810
unicodeNormalize = T.unpack . T.normalize NFC . T.pack
getNameMismatchPkg (fp, gpd)
| (show . gpdPackageName) gpd /= (FP.takeBaseName . toFilePath) fp
| (unicodeNormalize . show . gpdPackageName) gpd /= (unicodeNormalize . FP.takeBaseName . toFilePath) fp
= Just fp
| otherwise = Nothing
nameMismatchPkgs = mapMaybe getNameMismatchPkg packages
Expand Down

0 comments on commit 7ec9dd8

Please sign in to comment.