summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
3e39f84)
We already require GHC 6.8 to build, and that included stripPrefix
in Data.List.
import Panic
import SrcLoc
import Panic
import SrcLoc
data Flag m = Flag
{
flagName :: String, -- flag, without the leading -
data Flag m = Flag
{
flagName :: String, -- flag, without the leading -
= case [ (removeSpaces rest, optKind, flagDeprecated flag)
| flag <- spec,
let optKind = flagOptKind flag,
= case [ (removeSpaces rest, optKind, flagDeprecated flag)
| flag <- spec,
let optKind = flagOptKind flag,
- Just rest <- [maybePrefixMatch (flagName flag) arg],
+ Just rest <- [stripPrefix (flagName flag) arg],
arg_ok optKind rest arg ]
of
[] -> Nothing
arg_ok optKind rest arg ]
of
[] -> Nothing
import Control.Monad ( when )
import Data.Char
import Control.Monad ( when )
import Data.Char
-import Data.List ( intersperse )
import System.FilePath
import System.IO ( stderr, hPutChar )
import System.FilePath
import System.IO ( stderr, hPutChar )
-- We used to use "-optdep-flag -optdeparg", so for legacy applications
-- we need to strip the "-optdep" off of the arg
deOptDep :: String -> String
-- We used to use "-optdep-flag -optdeparg", so for legacy applications
-- we need to strip the "-optdep" off of the arg
deOptDep :: String -> String
-deOptDep x = case maybePrefixMatch "-optdep" x of
+deOptDep x = case stripPrefix "-optdep" x of
Just rest -> rest
Nothing -> x
Just rest -> rest
Nothing -> x
munge_paths = map munge_path
munge_path p
munge_paths = map munge_path
munge_path p
- | Just p' <- maybePrefixMatch "$topdir" p = top_dir ++ p'
- | Just p' <- maybePrefixMatch "$httptopdir" p = toHttpPath top_dir ++ p'
+ | Just p' <- stripPrefix "$topdir" p = top_dir ++ p'
+ | Just p' <- stripPrefix "$httptopdir" p = toHttpPath top_dir ++ p'
| otherwise = p
toHttpPath p = "file:///" ++ p
| otherwise = p
toHttpPath p = "file:///" ++ p
-- (lookup_str "foo") looks for the flag -foo=X or -fooX,
-- and returns the string X
lookup_str sw
-- (lookup_str "foo") looks for the flag -foo=X or -fooX,
-- and returns the string X
lookup_str sw
- = case firstJust (map (maybePrefixMatch sw) staticFlags) of
+ = case firstJust (map (stripPrefix sw) staticFlags) of
Just ('=' : str) -> Just str
Just str -> Just str
Nothing -> Nothing
Just ('=' : str) -> Just str
Just str -> Just str
Nothing -> Nothing
import UniqFM
import DynFlags
import Ctype
import UniqFM
import DynFlags
import Ctype
-import Util ( maybePrefixMatch, readRational )
+import Util ( readRational )
import Control.Monad
import Data.Bits
import Control.Monad
import Data.Bits
Just (c3,i3) ->
let str = [c1,c2,c3] in
case [ (c,rest) | (p,c) <- silly_escape_chars,
Just (c3,i3) ->
let str = [c1,c2,c3] in
case [ (c,rest) | (p,c) <- silly_escape_chars,
- Just rest <- [maybePrefixMatch p str] ] of
+ Just rest <- [stripPrefix p str] ] of
(escape_char,[]):_ -> do
setInput i3
return escape_char
(escape_char,[]):_ -> do
setInput i3
return escape_char
-- * Comparisons
isEqual, eqListBy,
-- * Comparisons
isEqual, eqListBy,
- thenCmp, cmpList, maybePrefixMatch,
removeSpaces,
-- * Transitive closures
removeSpaces,
-- * Transitive closures
--- This (with a more general type) is Data.List.stripPrefix from GHC 6.8.
--- This definition can be removed once we require at least 6.8 to build.
-maybePrefixMatch :: String -> String -> Maybe String
-maybePrefixMatch [] rest = Just rest
-maybePrefixMatch (_:_) [] = Nothing
-maybePrefixMatch (p:pat) (r:rest)
- | p == r = maybePrefixMatch pat rest
- | otherwise = Nothing
-
removeSpaces :: String -> String
removeSpaces = reverse . dropWhile isSpace . reverse . dropWhile isSpace
\end{code}
removeSpaces :: String -> String
removeSpaces = reverse . dropWhile isSpace . reverse . dropWhile isSpace
\end{code}