forked from GitHub/gf-core
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.
This commit is contained in:
@@ -77,7 +77,7 @@ data Phase = Preproc | Convert | Compile | Link
|
|||||||
deriving (Show,Eq,Ord)
|
deriving (Show,Eq,Ord)
|
||||||
|
|
||||||
data Encoding = UTF_8 | ISO_8859_1 | CP_1251
|
data Encoding = UTF_8 | ISO_8859_1 | CP_1251
|
||||||
deriving (Show,Eq,Ord)
|
deriving (Eq,Ord)
|
||||||
|
|
||||||
data OutputFormat = FmtPGF
|
data OutputFormat = FmtPGF
|
||||||
| FmtJavaScript
|
| FmtJavaScript
|
||||||
@@ -186,11 +186,10 @@ moduleOptionsGFO :: ModuleOptions -> [(String,String)]
|
|||||||
moduleOptionsGFO (ModuleOptions o) =
|
moduleOptionsGFO (ModuleOptions o) =
|
||||||
maybe [] (\x -> [("language",x)]) (optSpeechLanguage mfs)
|
maybe [] (\x -> [("language",x)]) (optSpeechLanguage mfs)
|
||||||
++ maybe [] (\x -> [("startcat",x)]) (optStartCat 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 [])
|
++ (if optErasing mfs then [("erasing","on")] else [])
|
||||||
where
|
where
|
||||||
mfs = o defaultModuleFlags
|
mfs = o defaultModuleFlags
|
||||||
e2s e = maybe [] id $ lookup e [(s,e) | (e,s) <- encodings]
|
|
||||||
|
|
||||||
-- Option manipulation
|
-- Option manipulation
|
||||||
|
|
||||||
@@ -475,6 +474,9 @@ encodings =
|
|||||||
("latin1", ISO_8859_1)
|
("latin1", ISO_8859_1)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
instance Show Encoding where
|
||||||
|
show = lookupShow encodings
|
||||||
|
|
||||||
lookupShow :: Eq a => [(String,a)] -> a -> String
|
lookupShow :: Eq a => [(String,a)] -> a -> String
|
||||||
lookupShow xs z = fromMaybe "lookupShow" $ lookup z [(y,x) | (x,y) <- xs]
|
lookupShow xs z = fromMaybe "lookupShow" $ lookup z [(y,x) | (x,y) <- xs]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user