From c9b6b5e89b9f75bc40a9964fdd154242dd4ed45b Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Wed, 16 Jan 2008 15:43:17 +0000 Subject: [PATCH 1/1] Fix slash direction on Windows with the new filePath code --- compiler/main/DriverPipeline.hs | 23 ++++++++++++++--------- compiler/utils/Util.lhs | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index e14d9b7..88b6b90 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -582,17 +582,22 @@ runPhase :: Phase -- Do this phase first -- Unlit phase runPhase (Unlit sf) _stop dflags _basename _suff input_fn get_output_fn maybe_loc - = do let unlit_flags = getOpts dflags opt_L - -- The -h option passes the file name for unlit to put in a #line directive + = do output_fn <- get_output_fn dflags (Cpp sf) maybe_loc - SysTools.runUnlit dflags - (map SysTools.Option unlit_flags ++ - [ SysTools.Option "-h" - , SysTools.Option input_fn - , SysTools.FileOption "" input_fn - , SysTools.FileOption "" output_fn - ]) + let unlit_flags = getOpts dflags opt_L + flags = map SysTools.Option unlit_flags ++ + [ -- The -h option passes the file name for unlit to + -- put in a #line directive + SysTools.Option "-h" + -- cpp interprets \b etc as escape sequences, + -- so we use / for filenames in pragmas + , SysTools.Option $ reslash Forwards $ normalise input_fn + , SysTools.FileOption "" input_fn + , SysTools.FileOption "" output_fn + ] + + SysTools.runUnlit dflags flags return (Cpp sf, dflags, maybe_loc, output_fn) diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs index 90e7042..b967917 100644 --- a/compiler/utils/Util.lhs +++ b/compiler/utils/Util.lhs @@ -70,6 +70,7 @@ module Util ( splitLongestPrefix, escapeSpaces, parseSearchPath, + Direction(..), reslash, ) where -- XXX This define is a bit of a hack, and should be done more nicely @@ -841,4 +842,17 @@ searchPathSeparator = ';' #else searchPathSeparator = ':' #endif + +data Direction = Forwards | Backwards + +reslash :: Direction -> FilePath -> FilePath +reslash d = f + where f ('/' : xs) = slash : f xs + f ('\\' : xs) = slash : f xs + f (x : xs) = x : f xs + f "" = "" + slash = case d of + Forwards -> '/' + Backwards -> '\\' \end{code} + -- 1.7.10.4