[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:37 UTC 2010
The following commit has been merged in the master branch:
commit 3b6282840ba956cca35486a78e0333cbb0ffae3f
Author: John Goerzen <jgoerzen at complete.org>
Date: Mon Nov 15 07:21:28 2004 +0100
Basic printf is working
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.5--patch-40)
diff --git a/ChangeLog b/ChangeLog
index ac81050..9164a46 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 00:21:28 GMT John Goerzen <jgoerzen at complete.org> patch-40
+
+ Summary:
+ Basic printf is working
+ Revision:
+ missingh--head--0.5--patch-40
+
+
+ modified files:
+ ChangeLog libsrc/MissingH/Printf.hs
+ libsrc/MissingH/Printf/Printer.lhs
+
+
2004-11-14 23:53:25 GMT John Goerzen <jgoerzen at complete.org> patch-39
Summary:
diff --git a/libsrc/MissingH/Printf.hs b/libsrc/MissingH/Printf.hs
index 96c3dea..7fdc0ff 100644
--- a/libsrc/MissingH/Printf.hs
+++ b/libsrc/MissingH/Printf.hs
@@ -46,13 +46,14 @@ module MissingH.Printf(-- * Variable-Argument Ouptut
PFRun,
PFType(..),
IOPFRun,
+ get_conversion_func
) where
import MissingH.Str
import Data.List
import System.IO
import MissingH.Printf.Types
-
+import MissingH.Printf.Printer(get_conversion_func)
v :: PFType a => a -> Value
v = toValue
@@ -60,9 +61,16 @@ v = toValue
sprintf :: String -> [Value] -> String
sprintf [] [] = []
+sprintf ('%' : '%' : xs) y = '%' : sprintf xs y
+{-
sprintf ('%' : xs) (y : ys) = (fromValue y) ++ sprintf xs ys
sprintf ('!' : xs) (y : ys) =
- show (((fromValue y)::Int) + 1) ++ sprintf xs ys
+ show (((fromValue y)::Int) + 1) ++ sprintf xs ys -}
+
+sprintf ('%' : t : xs) (y:ys) =
+ let cv = get_conversion_func t y [] Nothing Nothing
+ in
+ cv ++ sprintf xs ys
sprintf (x:xs) y = x : sprintf xs y
vsprintf :: (PFRun a) => String -> a
diff --git a/libsrc/MissingH/Printf/Printer.lhs b/libsrc/MissingH/Printf/Printer.lhs
index b6f5027..8b4e0bd 100644
--- a/libsrc/MissingH/Printf/Printer.lhs
+++ b/libsrc/MissingH/Printf/Printer.lhs
@@ -1,7 +1,8 @@
arch-tag: Printf printer declarations
\begin{code}
-module MissingH.Printf.Printer (get_conversion_func, thousandify, octalify, hexify) where
+module MissingH.Printf.Printer (get_conversion_func, thousandify, octalify, hexify,
+) where
import Maybe (fromMaybe)
import Numeric (showEFloat, showFFloat)
@@ -59,8 +60,8 @@ print_signed_int argv flags mw mp = res
res = let to_show = toInteger arg
shown = disp $ abs to_show
w = ( if ZeroPadded `elem` flags
- then (read preci `max` width - genericLength sign)::Width
- else (read preci)::Width )
+ then (preci `max` width - genericLength sign)::Width
+ else (preci)::Width )
sign = if to_show < 0 then "-" else plus_sign
num_zeroes = (w - genericLength shown) `max` 0
in sign ++ genericReplicate num_zeroes '0' ++ shown
@@ -72,8 +73,8 @@ print_unsigned_int base argv flags mw mp = res
where arg = (fromValue argv)::Integer
preci = read (fromMaybe "1" mp)
width = fromMaybe 0 mw
- w = if ZeroPadded `elem` flags then (read preci) `max` width
- else read preci
+ w = if ZeroPadded `elem` flags then (preci) `max` width
+ else preci
disp = case base of
'o' -> octalify
'x' -> hexify ({-lift-} lower_hex)
@@ -109,9 +110,9 @@ print_exponent_double e argv flags mw mp = res
else ""
keep_dot = AlternateForm `elem` flags
res = let to_show = (fromRational $ toRational arg) :: Double
- shown = showEFloat (Just (read preci)) (abs to_show) ""
+ shown = showEFloat (Just (preci)) (abs to_show) ""
sign = if to_show < 0 then "-" else plus_sign
- fix_prec0 = if (read preci) == 0
+ fix_prec0 = if (preci) == 0
then case break (== '.') shown of
(xs, _:_:ys)
| keep_dot -> xs ++ '.':ys
@@ -144,8 +145,8 @@ print_fixed_double f argv flags mw mp = res
fix_case | f == 'f' = map toLower
| otherwise = map toUpper
res = let to_show = (fromRational $ toRational arg) :: Double
- shown = showFFloat (Just (read preci)) (abs to_show) ""
- shown' = if add_dot && (read preci) == 0 then shown ++ "."
+ shown = showFFloat (Just (preci)) (abs to_show) ""
+ shown' = if add_dot && (preci) == 0 then shown ++ "."
else shown
sign = if to_show < 0 then "-" else plus_sign
num_zeroes = (width - genericLength shown' - genericLength sign)
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list