Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Always encode output as UTF-8 in cimplefmt. #48

Merged
merged 1 commit into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cimple.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ executable cimplefmt
main-is: cimplefmt.hs
build-depends:
base < 5
, bytestring
, cimple
, text

executable dump-ast
default-language: Haskell2010
Expand Down
2 changes: 2 additions & 0 deletions tools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ haskell_binary(
deps = [
"//hs-cimple",
hazel_library("base"),
hazel_library("bytestring"),
hazel_library("text"),
],
)

Expand Down
14 changes: 12 additions & 2 deletions tools/cimplefmt.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module Main (main) where

import qualified Data.ByteString as BS
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import Language.Cimple.IO (parseFile)
import Language.Cimple.Pretty (ppTranslationUnit)
import System.Environment (getArgs)
Expand All @@ -10,8 +13,15 @@ processFile source = do
putStrLn $ "Processing " ++ source
ast <- parseFile source
case ast of
Left err -> fail err
Right ok -> print $ ppTranslationUnit $ snd ok
Left err -> fail err
Right ok ->
BS.putStr
. Text.encodeUtf8
. Text.pack
. show
. ppTranslationUnit
. snd
$ ok


main :: IO ()
Expand Down