From 213cefa832ba19db4d41dc5c2f89634682b735fe Mon Sep 17 00:00:00 2001 From: Erik Hesselink Date: Tue, 17 Apr 2012 14:02:05 +0200 Subject: [PATCH] Remove infinite loop on MatchGroup without common prefix. In that case, the exact same MatchGroup would be fed to simplifyTerms again. Now, it is returned immediately, and only the rest of the terms are simplified. --- System/FilePath/GlobPattern.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/System/FilePath/GlobPattern.hs b/System/FilePath/GlobPattern.hs index 7299de0..91b1f09 100644 --- a/System/FilePath/GlobPattern.hs +++ b/System/FilePath/GlobPattern.hs @@ -117,8 +117,9 @@ simplifyTerms (MatchClass True (SRange a@[_] []):as) = simplifyTerms (MatchGroup []:as) = simplifyTerms as simplifyTerms (MatchGroup gs:as) = case commonPrefix gs of - (p,[]) -> simplifyTerms (MatchLiteral p : as) - (p,ss) -> simplifyTerms (MatchLiteral p : MatchGroup ss : as) + (p ,[]) -> simplifyTerms (MatchLiteral p : as) + ("",ss) -> MatchGroup ss : simplifyTerms as + (p ,ss) -> simplifyTerms (MatchLiteral p : MatchGroup ss : as) simplifyTerms (a:as) = a:simplifyTerms as commonPrefix :: [String] -> (String, [String])