From 2c7fc86533d9ec5d4a1e4c904f36227c239ba97b Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 19 May 2009 09:53:54 +0000 Subject: [PATCH] Fixed the processing of -D arguments on the command-line --- Main.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Main.hs b/Main.hs index 74260ab..4c40a73 100644 --- a/Main.hs +++ b/Main.hs @@ -140,14 +140,17 @@ optSearchPath s ps = return $ ps { csSearchPath = csSearchPath ps ++ splitOnColo optDefine :: String -> OptFunc optDefine s ps = return $ ps { csDefinitions = Map.insert name - ( case filter (null . snd) $ reads val of - ((n, _) : _) -> PreprocInt n - _ | null val -> PreprocNothing - | otherwise -> PreprocString val + ( case filter (null . snd) $ reads (safeTail val) of + ((n::Integer, _) : _) -> PreprocInt $ show n + [] | null val -> PreprocNothing + | otherwise -> PreprocString $ safeTail val ) (csDefinitions ps) } where (name, val) = span (/= '=') s + safeTail :: [a] -> [a] + safeTail [] = [] + safeTail (_:xs) = xs optImplicitModule :: String -> OptFunc optImplicitModule s ps = return $ ps { csImplicitModules = csImplicitModules ps ++ [s] } @@ -241,6 +244,8 @@ main = do case res of Left str -> putStrLn str Right initState -> do + when (csVerboseLevel initState >= 3) $ + liftIO $ hPutStrLn stderr $ "Initial state with args: " ++ show initState let operation = case csMode initState of ModePostC -> useOutputOptions (postCAnalyse fn) >> return () ModeFull -> evalStateT (unwrapFilesPassM $ compileFull fn fileStem) []