X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=ghc%2Futils%2Fhsc2hs%2FMain.hs;h=b37bb1e049831b45d238eba3a73193153095293a;hb=65142ed34d17ba68f871302a5d745f4e0b92c690;hp=4827905362d22a020fc84fdeed7b74c7a95fd332;hpb=c69fc1ae9231717e81f268d4d522c1770d9fdb14;p=ghc-hetmet.git diff --git a/ghc/utils/hsc2hs/Main.hs b/ghc/utils/hsc2hs/Main.hs index 4827905..b37bb1e 100644 --- a/ghc/utils/hsc2hs/Main.hs +++ b/ghc/utils/hsc2hs/Main.hs @@ -1,5 +1,5 @@ ------------------------------------------------------------------------ --- $Id: Main.hs,v 1.30 2001/04/02 16:10:05 rrt Exp $ +-- $Id: Main.hs,v 1.32 2001/07/24 05:49:32 ken Exp $ -- -- Program for converting .hsc files to .hs files, by converting the -- file into a C program which is run to generate the Haskell source. @@ -52,12 +52,12 @@ options = [ Option "I" [] (ReqArg (CompFlag . ("-I"++)) "DIR") "passed to the C compiler", Option "L" ["lflag"] (ReqArg LinkFlag "FLAG") "flag to pass to the linker", - Option "" ["no-compile"] (NoArg NoCompile) "stop after writing *_hsc_make.c", Option "i" ["include"] (ReqArg include "FILE") "as if placed in the source", Option "D" ["define"] (ReqArg define "NAME[=VALUE]") "as if placed in the source", Option "o" ["output"] (ReqArg Output "FILE") "name of main output file", Option "" ["help"] (NoArg Help) "display this help and exit", - Option "" ["version"] (NoArg Version) "output version information and exit"] + Option "" ["version"] (NoArg Version) "output version information and exit", + Option "" ["no-compile"] (NoArg NoCompile) "stop after writing *_hsc_make.c"] main :: IO () main = do @@ -433,7 +433,7 @@ output flags name toks = do progName = outDir++outBase++"_hsc_make" ++ progNameSuffix outHName = outDir++outBase++"_hsc.h" outCName = outDir++outBase++"_hsc.c" - + let execProgName | null outDir = "./"++progName | otherwise = progName @@ -649,19 +649,20 @@ outTokenC (pos, key, arg) = "def" -> case arg of 's':'t':'r':'u':'c':'t':' ':_ -> "" 't':'y':'p':'e':'d':'e':'f':' ':_ -> "" - 'i':'n':'l':'i':'n':'e':' ':_ -> - outCLine pos++ - "#ifndef __GNUC__\n\ - \extern\n\ - \#endif\n"++ - header++ - "\n#ifndef __GNUC__\n\ - \;\n\ - \#else\n"++ - body++ - "\n#endif\n" + 'i':'n':'l':'i':'n':'e':' ':arg' -> + case span (\c -> c /= '{' && c /= '=') arg' of + (header, body) -> + outCLine pos++ + "#ifndef __GNUC__\n\ + \extern inline\n\ + \#endif\n"++ + header++ + "\n#ifndef __GNUC__\n\ + \;\n\ + \#else\n"++ + body++ + "\n#endif\n" _ -> outCLine pos++arg++"\n" - where (header, body) = span (\c -> c /= '{' && c /= '=') arg _ | conditional key -> outCLine pos++"#"++key++" "++arg++"\n" _ -> ""