summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Capriotti <p.capriotti@gmail.com>2012-07-17 16:24:26 +0100
committerPaolo Capriotti <p.capriotti@gmail.com>2012-07-18 11:50:03 +0100
commit2b341fc43b244a3cc8bc174875241821d983e16e (patch)
treef6e300599b509a2b03716353294fa737b6423de8
parentf8a00d0e4ac1f94f6ccf3da3ee6c208cdbce8d65 (diff)
downloadhaskell-2b341fc43b244a3cc8bc174875241821d983e16e.tar.gz
Remove hPrintDump and make rule dump output more consistent (#7060)
The only difference between SevDump and SevOutput in defaultLogAction is an extra blank line, so we don't need a separate hPrintDump function. Also make -ddump-to-file consistent with the stdout version, by avoiding to add the extra empty line when dumping rules.
-rw-r--r--compiler/main/DynFlags.hs2
-rw-r--r--compiler/main/ErrUtils.lhs8
-rw-r--r--compiler/utils/Outputable.lhs10
3 files changed, 9 insertions, 11 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index b5ad8d11ce..6634efdca1 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -1017,7 +1017,7 @@ defaultLogAction :: LogAction
defaultLogAction dflags severity srcSpan style msg
= case severity of
SevOutput -> printSDoc msg style
- SevDump -> hPrintDump dflags stdout msg
+ SevDump -> printSDoc (msg $$ blankLine) style
SevInfo -> printErrs msg style
SevFatal -> printErrs msg style
_ -> do hPutChar stderr '\n'
diff --git a/compiler/main/ErrUtils.lhs b/compiler/main/ErrUtils.lhs
index 84722aa74a..1643128eb7 100644
--- a/compiler/main/ErrUtils.lhs
+++ b/compiler/main/ErrUtils.lhs
@@ -230,6 +230,9 @@ mkDumpDoc hdr doc
-- | Write out a dump.
-- If --dump-to-file is set then this goes to a file.
-- otherwise emit to stdout.
+--
+-- When hdr is empty, we print in a more compact format (no separators and
+-- blank lines)
dumpSDoc :: DynFlags -> DynFlag -> String -> SDoc -> IO ()
dumpSDoc dflags dflag hdr doc
= do let mFile = chooseDumpFile dflags dflag
@@ -247,7 +250,10 @@ dumpSDoc dflags dflag hdr doc
writeIORef gdref (Set.insert fileName gd)
createDirectoryIfMissing True (takeDirectory fileName)
handle <- openFile fileName mode
- hPrintDump dflags handle doc
+ let doc'
+ | null hdr = doc
+ | otherwise = doc $$ blankLine
+ defaultLogActionHPrintDoc dflags handle doc' defaultDumpStyle
hClose handle
-- write the dump to stdout
diff --git a/compiler/utils/Outputable.lhs b/compiler/utils/Outputable.lhs
index f74aaa84fe..710780062a 100644
--- a/compiler/utils/Outputable.lhs
+++ b/compiler/utils/Outputable.lhs
@@ -38,7 +38,6 @@ module Outputable (
colBinder, bold, keyword,
-- * Converting 'SDoc' into strings and outputing it
- hPrintDump,
printForC, printForAsm, printForUser, printForUserPartWay,
pprCode, mkCodeStyle,
showSDoc, showSDocOneLine,
@@ -91,7 +90,7 @@ import qualified Data.IntMap as IM
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Word
-import System.IO ( Handle, hFlush )
+import System.IO ( Handle )
import System.FilePath
@@ -330,13 +329,6 @@ ifPprDebug d = SDoc $ \ctx ->
\end{code}
\begin{code}
-hPrintDump :: DynFlags -> Handle -> SDoc -> IO ()
-hPrintDump dflags h doc = do
- Pretty.printDoc PageMode (pprCols dflags) h
- (runSDoc better_doc (initSDocContext dflags defaultDumpStyle))
- hFlush h
- where
- better_doc = doc $$ blankLine
printForUser :: DynFlags -> Handle -> PrintUnqualified -> SDoc -> IO ()
printForUser dflags handle unqual doc