@@ -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.
2425stripExtractVersion :: String -> String
2526stripExtractVersion 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