[project @ 2004-02-02 10:07:37 by simonmar]
[ghc-hetmet.git] / ghc / compiler / main / SysTools.lhs
index 127612d..0908f2c 100644 (file)
@@ -19,6 +19,7 @@ module SysTools (
        setPgms,
        setPgma,
        setPgml,
+       setPgmDLL,
 #ifdef ILX
        setPgmI,
        setPgmi,
@@ -104,7 +105,7 @@ import Foreign
 import CString         ( CString, peekCString )
 #endif
 
-#if __GLASGOW_HASKELL__ < 601
+#if __GLASGOW_HASKELL__ < 603
 import Foreign         ( withMany, withArray0, nullPtr, Ptr )
 import CForeign                ( CString, withCString, throwErrnoIfMinus1 )
 #else
@@ -434,6 +435,7 @@ setPgmm = writeIORef v_Pgm_m
 setPgms = writeIORef v_Pgm_s
 setPgma = writeIORef v_Pgm_a
 setPgml = writeIORef v_Pgm_l
+setPgmDLL = writeIORef v_Pgm_MkDLL
 #ifdef ILX
 setPgmI = writeIORef v_Pgm_I
 setPgmi = writeIORef v_Pgm_i
@@ -762,10 +764,19 @@ traceCmd phase_name cmd_line action
 
 -- -----------------------------------------------------------------------------
 -- rawSystem: run an external command
+--
+-- In GHC 6.2.1 there's a correct implementation of rawSystem in the
+-- library System.Cmd.  If we are compiling with an earlier version of
+-- GHC than this, we'd better have a copy of the correct implementation
+-- right here.
+
+-- If you ever alter this code, you must alter 
+--     libraries/base/System/Cmd.hs
+-- at the same time!  There are also exensive comments in System.Cmd
+-- thare are not repeated here -- go look!
 
-#if __GLASGOW_HASKELL__ < 601
 
--- This code is copied from System.Cmd on GHC 6.1.
+#if __GLASGOW_HASKELL__ < 603
 
 rawSystem :: FilePath -> [String] -> IO ExitCode
 
@@ -799,10 +810,15 @@ rawSystem cmd args = do
        n  -> return (ExitFailure n)
 
 translate :: String -> String
+-- Returns a string wrapped in double-quotes
+-- If the input string starts with double-quote, don't touch it
+-- If not, wrap it in double-quotes and double any backslashes
+--     foo\baz    -->  "foo\\baz"
+--     "foo\baz"  -->  "foo\baz"
+
 translate str@('"':_) = str -- already escaped.
 translate str = '"' : foldr escape "\"" str
   where escape '"'  str = '\\' : '"'  : str
-       escape '\\' str = '\\' : '\\' : str
        escape c    str = c : str
 
 foreign import ccall "rawSystem" unsafe