diff --git a/Cabal/src/Distribution/Simple/Program/Internal.hs b/Cabal/src/Distribution/Simple/Program/Internal.hs index add9dd74d71..745ed186395 100644 --- a/Cabal/src/Distribution/Simple/Program/Internal.hs +++ b/Cabal/src/Distribution/Simple/Program/Internal.hs @@ -17,21 +17,28 @@ import Prelude () -- | Extract the version number from the output of 'strip --version'. -- --- Invoking "strip --version" gives very inconsistent results. We ignore --- everything in parentheses (see #2497), look for the first word that starts --- with a number, and try parsing out the first two components of it. Non-GNU --- 'strip' doesn't appear to have a version flag. +-- Invoking "strip --version" gives very inconsistent results. We +-- ignore everything in parentheses (see #2497), look for the first +-- word that starts with a number, and try parsing out the first two +-- components of it. Non-GNU, non-LLVM 'strip' doesn't appear to have +-- a version flag. stripExtractVersion :: String -> String stripExtractVersion str = let numeric "" = False numeric (x : _) = isDigit x + closingParentheses = + [ ")" + , -- LLVM strip outputs "llvm-strip, compatible with GNU strip\nLLVM (http://llvm.org/):\n..." + "):" + ] + -- Filter out everything in parentheses. filterPar' :: Int -> [String] -> [String] filterPar' _ [] = [] filterPar' n (x : xs) | n >= 0 && "(" `isPrefixOf` x = filterPar' (n + 1) ((safeTail x) : xs) - | n > 0 && ")" `isSuffixOf` x = filterPar' (n - 1) xs + | n > 0 && any (`isSuffixOf` x) closingParentheses = filterPar' (n - 1) xs | n > 0 = filterPar' n xs | otherwise = x : filterPar' n xs