Commit 6ec1fb06 authored by sof@galois.com's avatar sof@galois.com

readerProc: split up text output using host's line termination convention

parent a2a8d11f
......@@ -704,7 +704,7 @@ builderMainLoop dflags filter_fn pgm real_args = do
readerProc chan hdl filter_fn =
(do str <- hGetContents hdl
loop (lines (filter_fn str)) Nothing)
loop (linesPlatform (filter_fn str)) Nothing)
`finally`
writeChan chan EOF
-- ToDo: check errors more carefully
......@@ -814,4 +814,22 @@ getProcessID :: IO Int
getProcessID = Posix.getProcessID
#endif
-- Divvy up text stream into lines, taking platform dependent
-- line termination into account.
linesPlatform :: String -> [String]
#if !defined(mingw32_HOST_OS)
linesPlatform ls = lines ls
#else
linesPlatform "" = []
linesPlatform xs =
case lineBreak xs of
(as,xs1) -> as : linesPlatform xs1
where
lineBreak "" = ("","")
lineBreak ('\r':'\n':xs) = ([],xs)
lineBreak ('\n':xs) = ([],xs)
lineBreak (x:xs) = let (as,bs) = lineBreak xs in (x:as,bs)
#endif
\end{code}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment