From a61ed6aedac50b8bf4972261473236dc6097a8fc Mon Sep 17 00:00:00 2001 From: sof Date: Sat, 1 Nov 2003 01:52:01 +0000 Subject: [PATCH] [project @ 2003-11-01 01:52:01 by sof] expandEnvVars.expandStrings: flatten the expanded strings so as to permit a substitution to expand into multiple elements of the final list. merge to stable. --- ghc/utils/ghc-pkg/Main.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ghc/utils/ghc-pkg/Main.hs b/ghc/utils/ghc-pkg/Main.hs index 421c903..324e7d9 100644 --- a/ghc/utils/ghc-pkg/Main.hs +++ b/ghc/utils/ghc-pkg/Main.hs @@ -406,7 +406,13 @@ expandEnvVars pkg defines force = do , extra_frameworks= e_frames }) where - expandStrings = mapM expandString + expandStrings vs = do + xs <- mapM expandString vs + -- Flatten the elements of the expanded list; this is + -- to permit substitutions for list-valued variables. e.g., + -- package_deps["${deps}"] where env var (say) 'deps' + -- is "base,haskell98,network" + return (concat (map (wordsBy (==',')) xs)) -- Just for fun, keep this in the IO monad. expandString :: String -> IO String @@ -430,6 +436,11 @@ expandEnvVars pkg defines force = do show nm) return "") +wordsBy :: (Char -> Bool) -> String -> [String] +wordsBy p s = case dropWhile p s of + "" -> [] + s' -> w : wordsBy p s'' where (w,s'') = break p s' + ----------------------------------------------------------------------------- getProgramName :: IO String -- 1.7.10.4