Repository : ssh://darcs.haskell.org//srv/darcs/packages/filepath On branch : master
http://hackage.haskell.org/trac/ghc/changeset/014dba4283b35a755894b333c931eedec6135290 >--------------------------------------------------------------- commit 014dba4283b35a755894b333c931eedec6135290 Author: Ian Lynagh <[email protected]> Date: Sun Aug 28 19:17:40 2011 +0100 System.FilePath.normalise "/" should be "/", not "/.". Fixes trac #3975 >--------------------------------------------------------------- System/FilePath/Internal.hs | 27 ++++++++++++++------------- 1 files changed, 14 insertions(+), 13 deletions(-) diff --git a/System/FilePath/Internal.hs b/System/FilePath/Internal.hs index 6336353..5e5b915 100644 --- a/System/FilePath/Internal.hs +++ b/System/FilePath/Internal.hs @@ -701,13 +701,17 @@ makeRelative root path -- > normalise "." == "." -- > Posix: normalise "./" == "./" -- > Posix: normalise "./." == "./" +-- > Posix: normalise "/" == "/" -- > Posix: normalise "bob/fred/." == "bob/fred/" normalise :: FilePath -> FilePath -normalise path = joinDrive (normaliseDrive drv) (f pth) +normalise path = joinDrive' (normaliseDrive drv) (f pth) ++ [pathSeparator | isDirPath pth] where (drv,pth) = splitDrive path + joinDrive' "" "" = "." + joinDrive' d p = joinDrive d p + isDirPath xs = lastSep xs || not (null xs) && last xs == '.' && lastSep (init xs) lastSep xs = not (null xs) && isPathSeparator (last xs) @@ -721,12 +725,7 @@ normalise path = joinDrive (normaliseDrive drv) (f pth) propSep (x:xs) = x : propSep xs propSep [] = [] - dropDots xs | all (== ".") xs = ["."] - dropDots xs = dropDots' [] xs - - dropDots' acc (".":xs) = dropDots' acc xs - dropDots' acc (x:xs) = dropDots' (x:acc) xs - dropDots' acc [] = reverse acc + dropDots = filter ("." /=) normaliseDrive :: FilePath -> FilePath normaliseDrive drive | isPosix = drive @@ -814,12 +813,14 @@ isRelative :: FilePath -> Bool isRelative = isRelativeDrive . takeDrive --- > isRelativeDrive "" == True --- > Windows: isRelativeDrive "c:\\" == False --- > Windows: isRelativeDrive "c:/" == False --- > Windows: isRelativeDrive "c:" == True --- > Windows: isRelativeDrive "\\\\foo" == False --- > Posix: isRelativeDrive "/" == False +-- Disable these tests for now, as we want to be able to run the +-- testsuite without doing a special TESTING compilation +-- -- > isRelativeDrive "" == True +-- -- > Windows: isRelativeDrive "c:\\" == False +-- -- > Windows: isRelativeDrive "c:/" == False +-- -- > Windows: isRelativeDrive "c:" == True +-- -- > Windows: isRelativeDrive "\\\\foo" == False +-- -- > Posix: isRelativeDrive "/" == False isRelativeDrive :: String -> Bool isRelativeDrive x = null x || maybe False (not . isPathSeparator . last . fst) (readDriveLetter x) _______________________________________________ Cvs-libraries mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-libraries
