[commit: nofib] master: nofib-analyize: Include % in LaTeX output (d224bbb)

git at git.haskell.org git at git.haskell.org
Sat Mar 15 16:18:58 UTC 2014


Repository : ssh://git@git.haskell.org/nofib

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/d224bbb3576f57923be1685c903c7bdbf9b34be3/nofib

>---------------------------------------------------------------

commit d224bbb3576f57923be1685c903c7bdbf9b34be3
Author: Joachim Breitner <breitner at kit.edu>
Date:   Sat Mar 15 16:36:14 2014 +0100

    nofib-analyize: Include % in LaTeX output
    
    I see no reason why this should be different from the text output,
    especially as it is important to distinguish absolute from relative
    values in the runtime column. It is also easier to remove the % (using
    search-and-replace) than to add it.


>---------------------------------------------------------------

d224bbb3576f57923be1685c903c7bdbf9b34be3
 nofib-analyse/Main.hs |   27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/nofib-analyse/Main.hs b/nofib-analyse/Main.hs
index ad043f5..a1340d9 100644
--- a/nofib-analyse/Main.hs
+++ b/nofib-analyse/Main.hs
@@ -586,10 +586,7 @@ ascii_summary_table latex (rbase:rs) (_:names) specs mb_restrict
         progs   = map BoxString (Map.keys rbase)
         rows0   = map TableRow (zipWith (:) progs (transpose columns))
 
-        rows1 = restrictRows mb_restrict rows0
-
-        rows | latex     = mungeForLaTeX rows1
-             | otherwise = rows1
+        rows = restrictRows mb_restrict rows0
 
         av_rows = map TableRow (zipWith (:) av_heads (transpose av_cols))
         w   = sUMMARY_FIELD_WIDTH
@@ -614,18 +611,6 @@ restrictRows (Just these) rows = filter keep_it rows
         keep_it TableLine = True
         keep_it _ = False
 
-mungeForLaTeX :: [TableRow] -> [TableRow]
-mungeForLaTeX = map transrow
-   where
-        transrow (TableRow boxes) = TableRow (map transbox boxes)
-        transrow row = row
-
-        transbox (BoxString s) = BoxString (foldr transchar "" s)
-        transbox box = box
-
-        transchar '_' s = '\\':'_':s
-        transchar c s = c:s
-
 table_layout :: Int -> Int -> Layout
 table_layout n w boxes = foldr (.) id $ intersperse (str (space 1)) $ zipWith ($) fns boxes
  where fns = (str . rjustify 15 . show ) :
@@ -949,10 +934,14 @@ latexTableLayout boxes =
   foldr (.) id . intersperse (str " & ") . map abox $ boxes
   where 
         abox (RunFailed NotDone) = id
-        abox s = str (foldr transchar "" (show s))
+        abox s = str (mungeForLaTeX (show s))
 
-        transchar '%' s = s  -- leave out the percentage signs
-        transchar c   s = c : s
+mungeForLaTeX :: String -> String
+mungeForLaTeX = foldr transchar ""
+   where
+        transchar '_' s = '\\':'_':s
+        transchar '%' s = '\\':'%':s
+        transchar c s = c:s
 
 -- -----------------------------------------------------------------------------
 -- General Utils



More information about the ghc-commits mailing list