[commit: packages/filepath] master: Refactor: use hasTrailingPathSeparator (9db8af2)
git at git.haskell.org
git at git.haskell.org
Thu Mar 19 11:33:51 UTC 2015
Repository : ssh://git@git.haskell.org/filepath
On branch : master
Link : http://git.haskell.org/packages/filepath.git/commitdiff/9db8af2520acdfeba945c6221ed3db6b2c3ba81f
>---------------------------------------------------------------
commit 9db8af2520acdfeba945c6221ed3db6b2c3ba81f
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date: Sun Sep 14 18:26:21 2014 +0200
Refactor: use hasTrailingPathSeparator
hasTrailingPathSeparator is defined as:
hasTrailingPathSeparator "" = False
hasTrailingPathSeparator x = isPathSeparator (last x)
>---------------------------------------------------------------
9db8af2520acdfeba945c6221ed3db6b2c3ba81f
System/FilePath/Internal.hs | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/System/FilePath/Internal.hs b/System/FilePath/Internal.hs
index 36e88e4..977eae9 100644
--- a/System/FilePath/Internal.hs
+++ b/System/FilePath/Internal.hs
@@ -683,7 +683,7 @@ equalFilePath a b = f a == f b
f x | isWindows = dropTrailSlash $ map toLower $ normalise x
| otherwise = dropTrailSlash $ normalise x
- dropTrailSlash x | length x >= 2 && isPathSeparator (last x) = init x
+ dropTrailSlash x | length x >= 2 && hasTrailingPathSeparator x = init x
| otherwise = x
@@ -758,9 +758,8 @@ normalise path = joinDrive' (normaliseDrive drv) (f pth)
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)
+ isDirPath xs = hasTrailingPathSeparator xs
+ || not (null xs) && last xs == '.' && hasTrailingPathSeparator (init xs)
f = joinPath . dropDots . splitDirectories . propSep
@@ -876,7 +875,7 @@ isRelative = isRelativeDrive . takeDrive
-- current directory on the drive with the specified letter."
isRelativeDrive :: String -> Bool
isRelativeDrive x = null x ||
- maybe False (not . isPathSeparator . last . fst) (readDriveLetter x)
+ maybe False (not . hasTrailingPathSeparator . fst) (readDriveLetter x)
-- | @not . 'isRelative'@
More information about the ghc-commits
mailing list