[commit: packages/filepath] master: Bug fix: isDrive "" == False (f9ae34b)

git at git.haskell.org git at git.haskell.org
Thu Mar 19 11:34:10 UTC 2015


Repository : ssh://git@git.haskell.org/filepath

On branch  : master
Link       : http://git.haskell.org/packages/filepath.git/commitdiff/f9ae34b04cf5644e31f2920a001af37edcd3f946

>---------------------------------------------------------------

commit f9ae34b04cf5644e31f2920a001af37edcd3f946
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Mon Sep 15 09:48:41 2014 +0200

    Bug fix: isDrive "" == False
    
    isDrive is only called from `dropTrailingPathSeparator` and `combineAlways`.
    Both times occur after a check if the argument is not empty (i.e. null for
    combineAlways, and hasTrailingPathSeparator for dropTrailingPathSeparator). So
    this change is safe.


>---------------------------------------------------------------

f9ae34b04cf5644e31f2920a001af37edcd3f946
 System/FilePath/Internal.hs | 3 ++-
 changelog.md                | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/System/FilePath/Internal.hs b/System/FilePath/Internal.hs
index f85e635..b82b2ab 100644
--- a/System/FilePath/Internal.hs
+++ b/System/FilePath/Internal.hs
@@ -422,8 +422,9 @@ hasDrive = not . null . takeDrive
 -- > Posix:   isDrive "/foo" == False
 -- > Windows: isDrive "C:\\" == True
 -- > Windows: isDrive "C:\\foo" == False
+-- >          isDrive "" == False
 isDrive :: FilePath -> Bool
-isDrive = null . dropDrive
+isDrive x = not (null x) && null (dropDrive x)
 
 
 ---------------------------------------------------------------------
diff --git a/changelog.md b/changelog.md
index 13dad0e..2825edb 100644
--- a/changelog.md
+++ b/changelog.md
@@ -4,6 +4,8 @@
 
   * Bundled with GHC 7.10.1
 
+  * Bug fix: `isDrive ""` now retuns `False`, instead of `True`.
+
   * Bug fix: on Windows, `dropTrailingPathSeparator "/"` now returns `"/"`
     unchanged, instead of the normalised `"\\"`.
 



More information about the ghc-commits mailing list