Skip to content

Commit 86306a9

Browse files
committed
Merge remote-tracking branch 'github/pr/178'
2 parents bb21b46 + d7ff6d6 commit 86306a9

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

System/FilePath/Internal.hs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,7 @@ makeRelative root path
984984
-- > Posix: normalise "./bob/fred/" == "bob/fred/"
985985
-- > Windows: normalise "c:\\file/bob\\" == "C:\\file\\bob\\"
986986
-- > Windows: normalise "c:\\" == "C:\\"
987+
-- > Windows: normalise "c:\\\\\\\\" == "C:\\"
987988
-- > Windows: normalise "C:.\\" == "C:"
988989
-- > Windows: normalise "\\\\server\\test" == "\\\\server\\test"
989990
-- > Windows: normalise "//server/test" == "\\\\server\\test"
@@ -1035,9 +1036,12 @@ normaliseDrive :: FILEPATH -> FILEPATH
10351036
normaliseDrive bs
10361037
| null bs = mempty
10371038
| isPosix = pack [pathSeparator]
1038-
| otherwise = if isJust $ readDriveLetter x2
1039-
then map toUpper x2
1040-
else x2
1039+
| Just (drv, _) <- readDriveLetter x2
1040+
= case unpack drv of
1041+
(x:_:[]) -> pack [toUpper x, _colon]
1042+
(x:_) -> pack [toUpper x, _colon, pathSeparator]
1043+
_ -> P.error "impossible"
1044+
| otherwise = x2
10411045
where
10421046
x2 = map repSlash bs
10431047
repSlash x = if isPathSeparator x then pathSeparator else x

tests/filepath-tests/TestGen.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,8 @@ tests =
814814
,("AFP_W.normalise (\"c:\\\\file/bob\\\\\") == (\"C:\\\\file\\\\bob\\\\\")", property $ AFP_W.normalise ("c:\\file/bob\\") == ("C:\\file\\bob\\"))
815815
,("W.normalise \"c:\\\\\" == \"C:\\\\\"", property $ W.normalise "c:\\" == "C:\\")
816816
,("AFP_W.normalise (\"c:\\\\\") == (\"C:\\\\\")", property $ AFP_W.normalise ("c:\\") == ("C:\\"))
817+
,("W.normalise \"c:\\\\\\\\\\\\\\\\\" == \"C:\\\\\"", property $ W.normalise "c:\\\\\\\\" == "C:\\")
818+
,("AFP_W.normalise (\"c:\\\\\\\\\\\\\\\\\") == (\"C:\\\\\")", property $ AFP_W.normalise ("c:\\\\\\\\") == ("C:\\"))
817819
,("W.normalise \"C:.\\\\\" == \"C:\"", property $ W.normalise "C:.\\" == "C:")
818820
,("AFP_W.normalise (\"C:.\\\\\") == (\"C:\")", property $ AFP_W.normalise ("C:.\\") == ("C:"))
819821
,("W.normalise \"\\\\\\\\server\\\\test\" == \"\\\\\\\\server\\\\test\"", property $ W.normalise "\\\\server\\test" == "\\\\server\\test")

0 commit comments

Comments
 (0)