[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36

John Goerzen jgoerzen at complete.org
Fri Apr 23 15:23:44 UTC 2010


The following commit has been merged in the master branch:
commit 81836611c6513fa36e144f5b90da392b54db6a04
Author: Jeroen Leeuwestein <jeroenleeuwestein at gmail.com>
Date:   Sat Jan 10 21:00:28 2009 +0100

    Bug and patch for MissingH filename globbing
    
    Hello,
    
    Recently, I came across the HSH library. It looks really nice and I'm
    planning on using it for writing a make-like tool in Haskell.
    
    However, I discovered some unexpected behaviour of the glob function,
    which I traced down to MissingH's System.Path.Glob. It seems to have
    some trouble with patterns starting with "*".
    
    I patched this module, using the newest version from the git repository,
    so it gives (what I believe to be) the correct results for the erroneous
    cases. Please read the comment in the patch to see what these cases are.
    
    If there is something technically wrong with the patch (I am quite new
    to git and to creating/submitting patches in general), please let me
    know. Or, if my solution is broken, then just regard this e-mail as a
    bug report.
    
    Regards, and thanks in advance,
    Jeroen Leeuwestein
    (some random computer science student from The Netherlands)
    
    From e9acff1f287831c8e815faf14fbc127050c9e323 Mon Sep 17 00:00:00 2001
    From: Jeroen Leeuwestein <jeroenleeuwestein at gmail.com>
    Date: Sat, 10 Jan 2009 17:54:32 +0100
    Subject: [PATCH] Fix a few globbing bugs.
    
    Setup a test in an empty directory:
      mkdir A
      touch A/text.txt
    
    glob "*"
      old result: ["/A"]
      new result: ["A"]
    glob $ "*/*" -- or anything starting with a star and then a non-wildcard character
      old result: []
      new result: ["A/text.txt"]
    glob $ "/*"
      old result: ["//root", ...]
      new result: ["/root", ...]

diff --git a/src/System/Path/Glob.hs b/src/System/Path/Glob.hs
index 27fbd0f..a5ee12d 100644
--- a/src/System/Path/Glob.hs
+++ b/src/System/Path/Glob.hs
@@ -70,8 +70,11 @@ vGlob fs fn =
 
 expandGlob :: HVFS a => a -> FilePath -> IO [FilePath]
 expandGlob fs fn =
-    case dirname of
-      "." -> runGlob fs "." basename
+    case dirnameslash of
+      "./" -> runGlob fs "." basename
+      "/"  -> do
+              rgs <- runGlob fs "/" basename
+              return $ map ('/' :) rgs
       _ -> do dirlist <- if hasWild dirname
                              then expandGlob fs dirname
                              else return [dirname]
@@ -91,7 +94,10 @@ expandGlob fs fn =
           expandWildBase :: FilePath -> IO [FilePath]
           expandWildBase dname =
               do dirglobs <- runGlob fs dname basename
-                 return $ map (\globfn -> dname ++ "/" ++ globfn) dirglobs
+                 return $ map withD dirglobs
+                 where withD = case dname of
+                                 ""  -> id
+                                 _   -> \globfn -> dname ++ "/" ++ globfn
 
           expandNormalBase :: FilePath -> IO [FilePath]
           expandNormalBase dname =

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list