From 6ec1fb0666d5493c236f856e8512a78700dd2b07 Mon Sep 17 00:00:00 2001 From: "sof@galois.com" Date: Tue, 13 Jun 2006 23:26:05 +0000 Subject: [PATCH] readerProc: split up text output using host's line termination convention --- compiler/main/SysTools.lhs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs index eee3e1a..4e5c583 100644 --- a/compiler/main/SysTools.lhs +++ b/compiler/main/SysTools.lhs @@ -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} -- 1.7.10.4