aboutsummaryrefslogtreecommitdiff
path: root/Utility/Format.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-12-22 20:21:42 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-12-23 01:08:18 -0400
commitdb964e358f16d19e9a2e6124d6be8a9c87fdd88b (patch)
tree27617e53edb4540da5f25ae38f43ec7d3d9b63cf /Utility/Format.hs
parenteb7ef6264ee57f69520960ae818ad0b94e5873c2 (diff)
reorg
Diffstat (limited to 'Utility/Format.hs')
-rw-r--r--Utility/Format.hs9
1 files changed, 4 insertions, 5 deletions
diff --git a/Utility/Format.hs b/Utility/Format.hs
index 804dbff4c..d16708701 100644
--- a/Utility/Format.hs
+++ b/Utility/Format.hs
@@ -36,10 +36,6 @@ data Frag = Const String | Var String Padding
- justification. -}
type Padding = Int
-empty :: Frag -> Bool
-empty (Const "") = True
-empty _ = False
-
{- Expands a Format using some variables, generating a formatted string.
- This can be repeatedly called, efficiently. -}
format :: Format -> M.Map String String -> String
@@ -63,7 +59,7 @@ gen :: FormatString -> Format
gen = filter (not . empty) . fuse [] . scan [] . decode_c
where
-- The Format is built up in reverse, for efficiency,
- -- and can have adjacent Consts. Fusing it fixes both
+ -- and can have many adjacent Consts. Fusing it fixes both
-- problems.
fuse f [] = f
fuse f (Const c1:Const c2:vs) = fuse f $ Const (c2++c1) : vs
@@ -90,6 +86,9 @@ gen = filter (not . empty) . fuse [] . scan [] . decode_c
novar v = "${" ++ reverse v
foundvar f v p cs = scan (Var (reverse v) p : f) cs
+empty :: Frag -> Bool
+empty (Const "") = True
+empty _ = False
{- Decodes a C-style encoding, where \n is a newline, \NNN is an octal
- encoded character, etc.