From: simonpj Date: Mon, 23 May 2005 09:50:26 +0000 (+0000) Subject: [project @ 2005-05-23 09:50:26 by simonpj] X-Git-Tag: Initial_conversion_from_CVS_complete~492 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=9af07e05719cba32911e8832eeee96bccb14ea1d;p=ghc-hetmet.git [project @ 2005-05-23 09:50:26 by simonpj] Clarify code for splitLongestPrefix; no effect on behaviour --- diff --git a/ghc/compiler/utils/Util.lhs b/ghc/compiler/utils/Util.lhs index 59bc87e..b16f6eb 100644 --- a/ghc/compiler/utils/Util.lhs +++ b/ghc/compiler/utils/Util.lhs @@ -913,11 +913,12 @@ joinFileName dir fname = dir ++ '/':fname -- string is returned in the first component (and the second one is just -- empty). splitLongestPrefix :: String -> (Char -> Bool) -> (String,String) -splitLongestPrefix s pred - = case pre of - [] -> (reverse suf, []) - (_:pre) -> (reverse pre, reverse suf) - where (suf,pre) = break pred (reverse s) +splitLongestPrefix str pred + | null r_pre = (str, []) + | otherwise = (reverse (tail r_pre), reverse r_suf) + -- 'tail' drops the char satisfying 'pred' + where + (r_suf, r_pre) = break pred (reverse str) replaceFilenameSuffix :: FilePath -> Suffix -> FilePath replaceFilenameSuffix file suf = basenameOf file `joinFileExt` suf