# HG changeset patch # User koda # Date 1351992917 -3600 # Node ID 497ec84e0c21abd168dd8d73724ab91922afa2f5 # Parent 97f41bdf077024622310e28503d313e7e602418e pas2c can read files without changing the process directory diff -r 97f41bdf0770 -r 497ec84e0c21 tools/PascalPreprocessor.hs --- a/tools/PascalPreprocessor.hs Sun Nov 04 02:13:25 2012 +0100 +++ b/tools/PascalPreprocessor.hs Sun Nov 04 02:35:17 2012 +0100 @@ -22,9 +22,9 @@ , ("S3D_DISABLED", "") ] -preprocess :: String -> IO String -preprocess fn = do - r <- runParserT (preprocessFile fn) (initDefines, [True]) "" "" +preprocess :: String -> String -> IO String +preprocess inputPath fn = do + r <- runParserT (preprocessFile (inputPath ++ fn)) (initDefines, [True]) "" "" case r of (Left a) -> do hPutStrLn stderr (show a) @@ -79,7 +79,7 @@ char '"' spaces char '}' - f <- liftIO (readFile fn `catch` error ("File not found: " ++ fn)) + f <- liftIO (readFile (inputPath ++ fn) `catch` error ("File not found: " ++ fn)) c <- getInput setInput $ f ++ c return "" diff -r 97f41bdf0770 -r 497ec84e0c21 tools/pas2c.hs --- a/tools/pas2c.hs Sun Nov 04 02:13:25 2012 +0100 +++ b/tools/pas2c.hs Sun Nov 04 02:35:17 2012 +0100 @@ -96,7 +96,6 @@ pas2C :: String -> String -> String -> IO () pas2C fn inputPath outputPath = do - setCurrentDirectory inputPath s <- flip execStateT initState $ f fn renderCFiles s outputPath where @@ -110,7 +109,7 @@ print ("Preprocessing '" ++ fileName ++ ".pas'... ") fc' <- liftIO $ tryJust (guard . isDoesNotExistError) - $ preprocess (fileName ++ ".pas") + $ preprocess inputPath (fileName ++ ".pas") case fc' of (Left a) -> do modify (Map.insert fileName (System []))