Skip to content

Commit 63184d5

Browse files
authored
Merge pull request haskell#10787 from jasagredo/js/strip
Parse llvm-strip version
2 parents 579de9d + aa50fd9 commit 63184d5

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Cabal/src/Distribution/Simple/Program/Internal.hs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,28 @@ import Prelude ()
1717

1818
-- | Extract the version number from the output of 'strip --version'.
1919
--
20-
-- Invoking "strip --version" gives very inconsistent results. We ignore
21-
-- everything in parentheses (see #2497), look for the first word that starts
22-
-- with a number, and try parsing out the first two components of it. Non-GNU
23-
-- 'strip' doesn't appear to have a version flag.
20+
-- Invoking "strip --version" gives very inconsistent results. We
21+
-- ignore everything in parentheses (see #2497), look for the first
22+
-- word that starts with a number, and try parsing out the first two
23+
-- components of it. Non-GNU, non-LLVM 'strip' doesn't appear to have
24+
-- a version flag.
2425
stripExtractVersion :: String -> String
2526
stripExtractVersion str =
2627
let numeric "" = False
2728
numeric (x : _) = isDigit x
2829

30+
closingParentheses =
31+
[ ")"
32+
, -- LLVM strip outputs "llvm-strip, compatible with GNU strip\nLLVM (http://llvm.org/):\n..."
33+
"):"
34+
]
35+
2936
-- Filter out everything in parentheses.
3037
filterPar' :: Int -> [String] -> [String]
3138
filterPar' _ [] = []
3239
filterPar' n (x : xs)
3340
| n >= 0 && "(" `isPrefixOf` x = filterPar' (n + 1) ((safeTail x) : xs)
34-
| n > 0 && ")" `isSuffixOf` x = filterPar' (n - 1) xs
41+
| n > 0 && any (`isSuffixOf` x) closingParentheses = filterPar' (n - 1) xs
3542
| n > 0 = filterPar' n xs
3643
| otherwise = x : filterPar' n xs
3744

0 commit comments

Comments
 (0)