From: Simon Marlow Date: Wed, 7 Nov 2007 11:32:01 +0000 (+0000) Subject: FIX #1561: don't use tabs in pretty-printed output at all. X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=b23eb7d83a2434e6791b3ca8eeec7cfa74f63ffd;hp=da4dda13a3faf2ecc2138d16b7faa79cff264037 FIX #1561: don't use tabs in pretty-printed output at all. Tabs aren't guaranteed to be 8 spaces on every output device, so we shouldn't be using them. Instead I added a little optimisation to use chunks of 8 spaces for long indentations. --- diff --git a/compiler/utils/Pretty.lhs b/compiler/utils/Pretty.lhs index aa08f1c..9c94c8e 100644 --- a/compiler/utils/Pretty.lhs +++ b/compiler/utils/Pretty.lhs @@ -989,26 +989,29 @@ display mode IBOX(page_width) IBOX(ribbon_width) txt end doc other -> lay1 k s sl p - lay1 k s sl p = Str (indent k) `txt` (s `txt` lay2 (k PLUS sl) p) + lay1 k s sl p = indent k (s `txt` lay2 (k PLUS sl) p) lay2 k (NilAbove p) = nl_text `txt` lay k p lay2 k (TextBeside s sl p) = s `txt` (lay2 (k PLUS sl) p) lay2 k (Nest _ p) = lay2 k p lay2 k Empty = end + + -- optimise long indentations using LitString chunks of 8 spaces + indent n r | n GREQ ILIT(8) = LStr " "# 8# `txt` + indent (n MINUS ILIT(8)) r + | otherwise = Str (spaces n) `txt` r in lay ILIT(0) doc }} cant_fail = error "easy_display: NoDoc" -indent n | n GREQ ILIT(8) = '\t' : indent (n MINUS ILIT(8)) - | otherwise = spaces n - multi_ch n ch | n LTEQ ILIT(0) = "" | otherwise = ch : multi_ch (n MINUS ILIT(1)) ch spaces n | n LTEQ ILIT(0) = "" | otherwise = ' ' : spaces (n MINUS ILIT(1)) + \end{code} \begin{code}