[project @ 2001-01-13 12:11:00 by qrczak]
authorqrczak <unknown>
Sat, 13 Jan 2001 12:11:00 +0000 (12:11 +0000)
committerqrczak <unknown>
Sat, 13 Jan 2001 12:11:00 +0000 (12:11 +0000)
Remove #options construct: all released ghc versions understand multuple
{-# OPTIONS #-} pragmas.

ghc/docs/users_guide/utils.sgml
ghc/utils/hsc2hs/Main.hs
ghc/utils/hsc2hs/template-hsc.h

index 965115e..88d7aaa 100644 (file)
@@ -290,18 +290,6 @@ tags:
        </varlistentry>
 
        <varlistentry>
-         <term><literal>#option opt</literal></term>
-         <listitem>
-           <para>The specified Haskell compiler command-line option
-            is placed in the <literal>{-# OPTIONS #-}</literal> pragma
-            at the top of the Haskell file (see <xref
-            linkend="source-file-options">). This is needed because
-            <command>hsc2hs</command> emits its own <literal>OPTIONS</literal> pragma,
-            and only one such pragma is interpreted by GHC.</para>
-         </listitem>
-       </varlistentry>
-
-       <varlistentry>
          <term><literal>#def C_definition</literal></term>
          <listitem>
            <para>The definition (of a function, variable, struct or
index 3ab4411..726e2dd 100644 (file)
@@ -1,5 +1,5 @@
 -----------------------------------------------------------------------------
--- $Id: Main.hs,v 1.8 2001/01/12 22:54:23 qrczak Exp $
+-- $Id: Main.hs,v 1.9 2001/01/13 12:11:00 qrczak Exp $
 --
 -- (originally "GlueHsc.hs" by Marcin 'Qrczak' Kowalczyk)
 --
@@ -271,10 +271,12 @@ outHeaderCProg = concatMap $ \(key, arg) -> case key of
 
 outHeaderHs :: [Flag] -> Maybe String -> [(String, String)] -> String
 outHeaderHs flags inH toks =
-    "    hsc_begin_options();\n"++
+    "#if __GLASGOW_HASKELL__ && __GLASGOW_HASKELL__ < 409\n\
+    \    printf (\"{-# OPTIONS -optc-D__GLASGOW_HASKELL__=%d #-}\\n\", \
+    \__GLASGOW_HASKELL__);\n\
+    \#endif\n"++
     includeH++
-    concatMap outSpecial toks++
-    "    hsc_end_options();\n\n"
+    concatMap outSpecial toks
     where
     outSpecial (key, arg) = case key of
         "include" -> case inH of
@@ -283,7 +285,6 @@ outHeaderHs flags inH toks =
         "define" -> case inH of
             Nothing | goodForOptD arg -> outOption ("-optc-D"++toOptD arg)
             _ -> ""
-        "option" -> outOption arg
         _ | conditional key -> "#"++key++" "++arg++"\n"
         _ -> ""
     goodForOptD arg = case arg of
@@ -299,7 +300,8 @@ outHeaderHs flags inH toks =
         | name <- case inH of
             Nothing   -> [name | Include name <- flags]
             Just name -> ["\""++name++"\""]]
-    outOption s = "    hsc_option (\""++showCString s++"\");\n"
+    outOption s = "    printf (\"{-# OPTIONS %s #-}\\n\", \""++
+                  showCString s++"\");\n"
 
 outTokenHs :: Token -> String
 outTokenHs (Text s) = "    fputs (\""++showCString s++"\", stdout);\n"
@@ -307,7 +309,6 @@ outTokenHs (Special key arg) = case key of
     "include"           -> ""
     "define"            -> ""
     "undef"             -> ""
-    "option"            -> ""
     "def"               -> ""
     _ | conditional key -> "#"++key++" "++arg++"\n"
     "let"               -> ""
index c235f24..9b68c98 100644 (file)
 #define offsetof(t, f) ((size_t) &((t *)0)->f)
 #endif
 
-#if __GLASGOW_HASKELL__
-
-static int hsc_options_started;
-
-static void hsc_begin_options (void)
-{
-#if __GLASGOW_HASKELL__ < 409
-    printf ("{-# OPTIONS -optc-D__GLASGOW_HASKELL__=%d", __GLASGOW_HASKELL__);
-    hsc_options_started = 1;
-#else
-    hsc_options_started = 0;
-#endif
-}
-
-static void hsc_option (const char *s)
-{
-    if (!hsc_options_started)
-    {
-        printf ("{-# OPTIONS");
-        hsc_options_started = 1;
-    }
-    printf (" %s", s);
-}
-
-static void hsc_end_options (void)
-{
-    if (hsc_options_started) printf (" #-}\n");
-}
-
-#else /* !__GLASGOW_HASKELL__ */
-
-#define hsc_begin_options()
-#define hsc_option(s)
-#define hsc_end_options()
-
-#endif /* !__GLASGOW_HASKELL__ */
-
 #define hsc_const(x)                        \
     if ((x) < 0)                            \
         printf ("%ld", (long)(x));          \