setPgms,
setPgma,
setPgml,
+ setPgmDLL,
#ifdef ILX
setPgmI,
setPgmi,
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
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
-- -----------------------------------------------------------------------------
-- 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
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