[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36

John Goerzen jgoerzen at complete.org
Fri Apr 23 14:46:50 UTC 2010


The following commit has been merged in the master branch:
commit 173f05343cae0c190bb6e3e992abca4f8149f206
Author: John Goerzen <jgoerzen at complete.org>
Date:   Mon Nov 15 10:07:28 2004 +0100

    Width working
    
    Keywords:
    
    
    (jgoerzen at complete.org--projects/missingh--head--0.5--patch-46)

diff --git a/ChangeLog b/ChangeLog
index 436e494..7e5c703 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,19 @@
 # arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.5
 #
 
+2004-11-15 03:07:28 GMT	John Goerzen <jgoerzen at complete.org>	patch-46
+
+    Summary:
+      Width working
+    Revision:
+      missingh--head--0.5--patch-46
+
+
+    modified files:
+     ChangeLog libsrc/MissingH/Printf.hs
+     libsrc/MissingH/Printf/Printer.lhs
+
+
 2004-11-15 03:04:36 GMT	John Goerzen <jgoerzen at complete.org>	patch-45
 
     Summary:
diff --git a/libsrc/MissingH/Printf.hs b/libsrc/MissingH/Printf.hs
index 00e9ec0..bea3e8d 100644
--- a/libsrc/MissingH/Printf.hs
+++ b/libsrc/MissingH/Printf.hs
@@ -53,7 +53,7 @@ import MissingH.Str
 import Data.List
 import System.IO
 import MissingH.Printf.Types
-import MissingH.Printf.Printer(get_conversion_func)
+import MissingH.Printf.Printer(get_conversion_func, fix_width)
 import Text.Regex
 
 v :: PFType a => a -> Value
@@ -107,7 +107,7 @@ sprintf ('%' : xs) (y : ys) =
                  flags = mkflags flagstr
                  in
                  --(show width) ++ sprintf remainder ys
-                 (get_conversion_func fmt y flags width prec) ++ sprintf remainder ys
+                 fix_width flags width ((get_conversion_func fmt y flags width prec)) ++ sprintf remainder ys
          _ -> error $ "Problem matching format string at %" ++ xs
 
 sprintf (x:xs) y = x : sprintf xs y
diff --git a/libsrc/MissingH/Printf/Printer.lhs b/libsrc/MissingH/Printf/Printer.lhs
index 8b4e0bd..87ce43c 100644
--- a/libsrc/MissingH/Printf/Printer.lhs
+++ b/libsrc/MissingH/Printf/Printer.lhs
@@ -1,7 +1,7 @@
 arch-tag: Printf printer declarations
 
 \begin{code}
-module MissingH.Printf.Printer (get_conversion_func, thousandify, octalify, hexify,
+module MissingH.Printf.Printer (get_conversion_func, thousandify, octalify, hexify, fix_width
 ) where
 
 import Maybe (fromMaybe)
@@ -199,3 +199,25 @@ thousandify = reverse . t . reverse
           t xs = xs
 \end{code}
 
+
+----------------------------------------------------------------------
+-- FROM Ian Lynagh's Parser.lhs
+----------------------------------------------------------------------
+
+\begin{code}
+
+fix_width :: [Flag] -> Maybe Width -> String -> String
+fix_width _ Nothing e = e
+fix_width flags (Just w) e = exp_spaced
+    where
+          exp_num_spaces = abs w - genericLength e
+          exp_num_spaces' = 0 `max` exp_num_spaces
+          exp_spaces = genericReplicate exp_num_spaces' ' '
+          exp_left_padded = e ++ exp_spaces
+          exp_right_padded = exp_spaces ++ e
+          exp_spaced = if LeftAdjust `elem` flags
+                       then exp_left_padded
+                       else if w < 0 then exp_left_padded
+                                      else exp_right_padded
+
+\end{code}

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list