From 7fb6cab70c0ebf64f15f3cc140625a235000fda4 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Mon, 2 Jul 2007 11:42:08 +0000 Subject: [PATCH] Remove prefixMatch and suffixMatch from Util Use standard isPrefixOf/isSuffixOf instead. --- compiler/ghci/InteractiveUI.hs | 2 +- compiler/main/DynFlags.hs | 2 +- compiler/main/Main.hs | 2 +- compiler/main/StaticFlags.hs | 4 ++-- compiler/utils/Util.lhs | 11 +---------- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs index e1c9231..3f87d3c 100644 --- a/compiler/ghci/InteractiveUI.hs +++ b/compiler/ghci/InteractiveUI.hs @@ -628,7 +628,7 @@ lookupCommand str = do -- look for exact match first, then the first prefix match case [ c | c <- cmds, str == cmdName c ] of c:_ -> return (Just c) - [] -> case [ c | c@(s,_,_,_) <- cmds, prefixMatch str s ] of + [] -> case [ c | c@(s,_,_,_) <- cmds, str `isPrefixOf` s ] of [] -> return Nothing c:_ -> return (Just c) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index a5c1ab8..8509ffc 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -1429,7 +1429,7 @@ machdepCCOpts dflags sta = opt_Static in ( [ if sta then "-DDONT_WANT_WIN32_DLL_SUPPORT" else "" --- , if suffixMatch "mingw32" cTARGETPLATFORM then "-mno-cygwin" else "" +-- , if "mingw32" `isSuffixOf` cTARGETPLATFORM then "-mno-cygwin" else "" ], [ "-fno-defer-pop", #ifdef HAVE_GCC_MNO_OMIT_LFPTR diff --git a/compiler/main/Main.hs b/compiler/main/Main.hs index e9c8343..428f42e 100644 --- a/compiler/main/Main.hs +++ b/compiler/main/Main.hs @@ -70,7 +70,7 @@ main = argv0 <- getArgs let - (minusB_args, argv1) = partition (prefixMatch "-B") argv0 + (minusB_args, argv1) = partition ("-B" `isPrefixOf`) argv0 mbMinusB | null minusB_args = Nothing | otherwise = Just (drop 2 (last minusB_args)) diff --git a/compiler/main/StaticFlags.hs b/compiler/main/StaticFlags.hs index 9e13360..a162214 100644 --- a/compiler/main/StaticFlags.hs +++ b/compiler/main/StaticFlags.hs @@ -85,7 +85,7 @@ import Data.IORef import System.IO.Unsafe ( unsafePerformIO ) import Control.Monad ( when ) import Data.Char ( isDigit ) -import Data.List ( sort, intersperse, nub ) +import Data.List ----------------------------------------------------------------------------- -- Static flags @@ -369,7 +369,7 @@ isStaticFlag f = "fPIC", "fhpc" ] - || any (flip prefixMatch f) [ + || any (`isPrefixOf` f) [ "fliberate-case-threshold", "fmax-worker-args", "fhistory-size", diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs index 39fd64b..2d80c45 100644 --- a/compiler/utils/Util.lhs +++ b/compiler/utils/Util.lhs @@ -39,7 +39,7 @@ module Util ( -- comparisons isEqual, eqListBy, - thenCmp, cmpList, prefixMatch, suffixMatch, maybePrefixMatch, + thenCmp, cmpList, maybePrefixMatch, removeSpaces, -- strictness @@ -688,12 +688,6 @@ cmpList cmp (a:as) (b:bs) \end{code} \begin{code} -prefixMatch :: Eq a => [a] -> [a] -> Bool -prefixMatch [] _str = True -prefixMatch _pat [] = False -prefixMatch (p:ps) (s:ss) | p == s = prefixMatch ps ss - | otherwise = False - maybePrefixMatch :: String -> String -> Maybe String maybePrefixMatch [] rest = Just rest maybePrefixMatch (_:_) [] = Nothing @@ -701,9 +695,6 @@ maybePrefixMatch (p:pat) (r:rest) | p == r = maybePrefixMatch pat rest | otherwise = Nothing -suffixMatch :: Eq a => [a] -> [a] -> Bool -suffixMatch pat str = prefixMatch (reverse pat) (reverse str) - removeSpaces :: String -> String removeSpaces = reverse . dropWhile isSpace . reverse . dropWhile isSpace \end{code} -- 1.7.10.4