Skip to content

Commit

Permalink
fix: Always encode output as UTF-8 in cimplefmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Feb 4, 2022
1 parent 2e993c1 commit 6d1f8e2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
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

0 comments on commit 6d1f8e2

Please sign in to comment.