From 83318d075774f11282acf12f9eb2185bc8bd5464 Mon Sep 17 00:00:00 2001 From: bjorn Date: Wed, 25 Jun 2008 18:14:45 +0000 Subject: [PATCH] Include coding flag in .gfo files. Because the PGF file gets all the flags from the GFO file automatically, we get the coding flag in the PGF file too. This is undesirable, since PGF is supposed to always by in UTF-8. --- src/GF/Infra/Option.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/GF/Infra/Option.hs b/src/GF/Infra/Option.hs index 380cb3af7..f992d4f98 100644 --- a/src/GF/Infra/Option.hs +++ b/src/GF/Infra/Option.hs @@ -77,7 +77,7 @@ data Phase = Preproc | Convert | Compile | Link deriving (Show,Eq,Ord) data Encoding = UTF_8 | ISO_8859_1 | CP_1251 - deriving (Show,Eq,Ord) + deriving (Eq,Ord) data OutputFormat = FmtPGF | FmtJavaScript @@ -186,11 +186,10 @@ moduleOptionsGFO :: ModuleOptions -> [(String,String)] moduleOptionsGFO (ModuleOptions o) = maybe [] (\x -> [("language",x)]) (optSpeechLanguage mfs) ++ maybe [] (\x -> [("startcat",x)]) (optStartCat mfs) --- ++ maybe [] (\x -> [("coding", e2s x)]) (Just (optEncoding mfs)) + ++ [("coding", show (optEncoding mfs))] ++ (if optErasing mfs then [("erasing","on")] else []) where mfs = o defaultModuleFlags - e2s e = maybe [] id $ lookup e [(s,e) | (e,s) <- encodings] -- Option manipulation @@ -475,6 +474,9 @@ encodings = ("latin1", ISO_8859_1) ] +instance Show Encoding where + show = lookupShow encodings + lookupShow :: Eq a => [(String,a)] -> a -> String lookupShow xs z = fromMaybe "lookupShow" $ lookup z [(y,x) | (x,y) <- xs]