From 3a1213ab378bbcbf09b631e4066b3056ec699528 Mon Sep 17 00:00:00 2001 From: Meng Weng Wong Date: Sun, 20 Feb 2022 22:13:26 +0800 Subject: prepare for GHC 9, base 4.15, by using Buffer constructor interface --- src/compiler/GF/Text/Coding.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/compiler') diff --git a/src/compiler/GF/Text/Coding.hs b/src/compiler/GF/Text/Coding.hs index bac7938c0..2a89427fe 100644 --- a/src/compiler/GF/Text/Coding.hs +++ b/src/compiler/GF/Text/Coding.hs @@ -38,7 +38,7 @@ decodeUnicode :: TextEncoding -> ByteString -> String decodeUnicode enc bs = unsafePerformIO $ decodeUnicodeIO enc bs decodeUnicodeIO enc (PS fptr l len) = do - let bbuf = Buffer{bufRaw=fptr, bufState=ReadBuffer, bufSize=len, bufL=l, bufR=l+len} + let bbuf = (emptyBuffer fptr len ReadBuffer) { bufL=l, bufR=l+len } cbuf <- newCharBuffer 128 WriteBuffer case enc of TextEncoding {mkTextDecoder=mk} -> do decoder <- mk -- cgit v1.2.3 From 9b9905c0b27c59c1dd49cdfdfb6b14dddc8f77d0 Mon Sep 17 00:00:00 2001 From: Andreas Källberg Date: Wed, 18 May 2022 14:42:01 +0800 Subject: Always use UTF8 encoding in the gf executable This fixes many of the "Invalid character" messages you can get on different platforms. This has helped both with a nix-installation that didn't have global locale set and with a windows installation. --- src/compiler/GF/Main.hs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/compiler') diff --git a/src/compiler/GF/Main.hs b/src/compiler/GF/Main.hs index 7d4500c7b..1b90430d6 100644 --- a/src/compiler/GF/Main.hs +++ b/src/compiler/GF/Main.hs @@ -16,6 +16,7 @@ import Data.Version import System.Directory import System.Environment (getArgs) import System.Exit +import GHC.IO.Encoding -- import GF.System.Console (setConsoleEncoding) -- | Run the GF main program, taking arguments from the command line. @@ -23,6 +24,7 @@ import System.Exit -- Run @gf --help@ for usage info. main :: IO () main = do + setLocaleEncoding utf8 -- setConsoleEncoding uncurry mainOpts =<< getOptions -- cgit v1.2.3 From b7672b67a39fb46f3ba8dbacca96babb04fca82c Mon Sep 17 00:00:00 2001 From: Krasimir Angelov Date: Tue, 31 May 2022 10:15:50 +0200 Subject: adjust the -view command depending on the OS --- src/compiler/GF/Command/Commands.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/GF/Command/Commands.hs b/src/compiler/GF/Command/Commands.hs index 2f2e802e0..a6c66594f 100644 --- a/src/compiler/GF/Command/Commands.hs +++ b/src/compiler/GF/Command/Commands.hs @@ -4,6 +4,7 @@ module GF.Command.Commands ( options,flags, ) where import Prelude hiding (putStrLn,(<>)) -- GHC 8.4.1 clash with Text.PrettyPrint +import System.Info(os) import PGF @@ -882,11 +883,15 @@ pgfCommands = Map.fromList [ Right ty -> ty Nothing -> error ("Can't parse '"++str++"' as a type") optViewFormat opts = valStrOpts "format" "png" opts - optViewGraph opts = valStrOpts "view" "open" opts + optViewGraph opts = valStrOpts "view" open_cmd opts optNum opts = valIntOpts "number" 1 opts optNumInf opts = valIntOpts "number" 1000000000 opts ---- 10^9 takeOptNum opts = take (optNumInf opts) + open_cmd | os == "linux" = "xdg-open" + | os == "mingw32" = "start" + | otherwise = "open" + returnFromExprs es = return $ case es of [] -> pipeMessage "no trees found" _ -> fromExprs es @@ -1022,4 +1027,4 @@ stanzas = map unlines . chop . lines where #if !(MIN_VERSION_base(4,9,0)) errorWithoutStackTrace = error -#endif \ No newline at end of file +#endif -- cgit v1.2.3