X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=utils%2Fhsc2hs%2FMain.hs;h=a939f319d102d6ee04284e1f1b45c44abe75db10;hb=6bc54d1524cd6d10a978bef89bc6a8f0061adb66;hp=77b948f37a902cc129b927e606f9d8c447c9f878;hpb=373b03fe979abe898a387e02ca22007b768e343e;p=ghc-hetmet.git diff --git a/utils/hsc2hs/Main.hs b/utils/hsc2hs/Main.hs index 77b948f..a939f31 100644 --- a/utils/hsc2hs/Main.hs +++ b/utils/hsc2hs/Main.hs @@ -42,11 +42,7 @@ import System.IO ( openFile, IOMode(..), hClose ) #endif #if defined(__GLASGOW_HASKELL__) && !defined(BUILD_NHC) -#ifdef USING_COMPAT -import Compat.RawSystem ( rawSystem ) -#else import System.Cmd ( rawSystem ) -#endif #define HAVE_rawSystem #elif __NHC__ >= 117 import System.Cmd ( rawSystem ) @@ -133,7 +129,7 @@ main = do -- to find one by looking near the executable. This only -- works on Win32 or Hugs (getExecDir). On Unix, there's a wrapper -- script which specifies an explicit template flag. - flags_w_tpl <- if any template_flag flags then + flags_w_tpl0 <- if any template_flag flags then return flags else do mb_path <- getExecDir "/bin/hsc2hs.exe" @@ -147,6 +143,12 @@ main = do then return ((Template templ):) else return id return (add_opt flags) + + -- take only the last --template flag on the cmd line + let + (before,tpl:after) = break template_flag (reverse flags_w_tpl0) + flags_w_tpl = reverse (before ++ tpl : filter (not.template_flag) after) + case (files, errs) of (_, _) | any isHelp flags_w_tpl -> bye (usageInfo header options)