From: qrczak Date: Thu, 29 Mar 2001 00:01:18 +0000 (+0000) Subject: [project @ 2001-03-29 00:01:18 by qrczak] X-Git-Tag: Approximately_9120_patches~2260 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=721713b5d825b893ba0f29dce1fc237c963ecc18 [project @ 2001-03-29 00:01:18 by qrczak] Transform *.hsc into *.hs and optionally Hs*.h and Hs*.c (used to be *.hs and optionally *.hs.h and *.hs.c). Old names interacted badly with Makefile rules of the form '%: %.o' and looked ugly. --- diff --git a/ghc/docs/users_guide/utils.sgml b/ghc/docs/users_guide/utils.sgml index e9839af..ae50391 100644 --- a/ghc/docs/users_guide/utils.sgml +++ b/ghc/docs/users_guide/utils.sgml @@ -201,21 +201,21 @@ tags: The input file should end with .hsc. Output files get - names with the .hsc suffix replaced: + names with the *.hsc pattern replaced: - .hs + *.hs Haskell file - .hs.h + Hs*.h C header - .hs.c + Hs*.c C file diff --git a/ghc/lib/std/Makefile b/ghc/lib/std/Makefile index 186054f..a34ea3c 100644 --- a/ghc/lib/std/Makefile +++ b/ghc/lib/std/Makefile @@ -93,8 +93,8 @@ CLEAN_FILES += PrelGHC.hi $(foreach way, $(WAYS), PrelGHC.$(way)_hi) CLEAN_FILES += \ $(patsubst %.hsc, %.hs, $(HSC_SRCS)) \ - $(patsubst %.hsc, %.hs.c, $(HSC_SRCS)) \ - $(patsubst %.hsc, %.hs.h, $(HSC_SRCS)) + $(patsubst %.hsc, Hs%.c, $(HSC_SRCS)) \ + $(patsubst %.hsc, Hs%.h, $(HSC_SRCS)) #----------------------------------------------------------------------------- # Installation; need to install .hi files as well as libraries diff --git a/ghc/utils/hsc2hs/Main.hs b/ghc/utils/hsc2hs/Main.hs index 290e0db..42b412a 100644 --- a/ghc/utils/hsc2hs/Main.hs +++ b/ghc/utils/hsc2hs/Main.hs @@ -1,5 +1,5 @@ ------------------------------------------------------------------------ --- $Id: Main.hs,v 1.26 2001/03/16 09:07:41 qrczak Exp $ +-- $Id: Main.hs,v 1.27 2001/03/29 00:01:18 qrczak 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. @@ -45,7 +45,7 @@ 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 *.hs_make.c", + Option "" ["no-compile"] (NoArg NoCompile) "stop after writing HsMake*.c", Option "i" ["include"] (ReqArg include "FILE") "as if placed in the source", Option "" ["help"] (NoArg Help) "display this help and exit", Option "" ["version"] (NoArg Version) "output version information and exit"] @@ -381,23 +381,43 @@ cString quote = do _:_ -> do anyCharC_; cString quote ------------------------------------------------------------------------ --- Output the output files. +-- Write the output files. + +splitName :: String -> (String, String) +splitName name = + case break (== '/') name of + (file, []) -> ([], file) + (dir, sep:rest) -> (dir++sep:restDir, restFile) + where + (restDir, restFile) = splitName rest + +splitExt :: String -> (String, String) +splitExt name = + case break (== '.') name of + (base, []) -> (base, []) + (base, sepRest@(sep:rest)) + | null restExt -> (base, sepRest) + | otherwise -> (base++sep:restBase, restExt) + where + (restBase, restExt) = splitExt rest output :: [Flag] -> String -> [Token] -> IO () output flags name toks = let - baseName = case reverse name of - 'c':base -> reverse base - _ -> name++".hs" - cProgName = baseName++"_make.c" - oProgName = baseName++"_make.o" - progName = baseName++"_make" - outHsName = baseName - outHName = baseName++".h" - outCName = baseName++".c" + (dir, file) = splitName name + (base, ext) = splitExt file + cProgName = dir++"HsMake"++base++".c" + oProgName = dir++"HsMake"++base++".o" + progName = dir++"HsMake"++base + outHsName + | not (null ext) && last ext == 'c' = dir++base++init ext + | ext == ".hs" = dir++base++"_out.hs" + | otherwise = dir++base++".hs" + outHName = dir++"Hs"++base++".h" + outCName = dir++"Hs"++base++".c" - execProgName = case progName of - '/':_ -> progName - _ -> "./"++progName + execProgName + | null dir = "./"++progName + | otherwise = progName specials = [(pos, key, arg) | Special pos key arg <- toks] @@ -632,17 +652,12 @@ conditional _ = False outCLine :: SourcePos -> String outCLine (SourcePos name line) = - "# "++show line++" \""++showCString (basename name)++"\"\n" + "# "++show line++" \""++showCString (snd (splitName name))++"\"\n" outHsLine :: SourcePos -> String outHsLine (SourcePos name line) = " hsc_line ("++show (line + 1)++", \""++ - showCString (basename name)++"\");\n" - -basename :: String -> String -basename s = case break (== '/') s of - (name, []) -> name - (_, _:rest) -> basename rest + showCString (snd (splitName name))++"\");\n" showCString :: String -> String showCString = concatMap showCChar diff --git a/mk/suffix.mk b/mk/suffix.mk index 5f67ad6..94b0456 100644 --- a/mk/suffix.mk +++ b/mk/suffix.mk @@ -112,7 +112,7 @@ endif # BootingViaC #----------------------------------------------------------------------------- # hsc2hs Suffix Rules # -%.hs.c %.hs.h %.hs : %.hsc +Hs%.c Hs%.h %.hs : %.hsc $(HSC2HS) $< #-----------------------------------------------------------------------------