Commit 7fb6cab7 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Remove prefixMatch and suffixMatch from Util

Use standard isPrefixOf/isSuffixOf instead.
parent ce5c7f0d
......@@ -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)
......
......@@ -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
......
......@@ -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))
......
......@@ -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",
......
......@@ -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}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment