diff options
author | simonmar <unknown> | 2001-08-07 11:13:46 +0000 |
---|---|---|
committer | simonmar <unknown> | 2001-08-07 11:13:46 +0000 |
commit | f0bd52ecf6f6a16152ca826e4145da2ef3f0193e (patch) | |
tree | 18108a35813d6e1415d9f40bcd36cb0f80cb88eb /glafp-utils | |
parent | f7edc8782816d0c6befd9517743bc9e8ebc378c3 (diff) | |
download | haskell-f0bd52ecf6f6a16152ca826e4145da2ef3f0193e.tar.gz |
[project @ 2001-08-07 11:13:46 by simonmar]
Make this compile with newer GHCs.
Diffstat (limited to 'glafp-utils')
-rw-r--r-- | glafp-utils/nofib-analyse/Printf.lhs | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/glafp-utils/nofib-analyse/Printf.lhs b/glafp-utils/nofib-analyse/Printf.lhs index 8d65c0c978..feeea803ca 100644 --- a/glafp-utils/nofib-analyse/Printf.lhs +++ b/glafp-utils/nofib-analyse/Printf.lhs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: Printf.lhs,v 1.2 2001/02/21 16:24:34 simonmar Exp $ +-- $Id: Printf.lhs,v 1.3 2001/08/07 11:13:46 simonmar Exp $ -- (c) Simon Marlow 1997-2001 ----------------------------------------------------------------------------- @@ -12,7 +12,6 @@ > import CString > import IOExts > import ByteArray -> import PrelPack (unpackCString) > showFloat > :: Bool -- Always print decimal point @@ -28,7 +27,10 @@ > bUFSIZE = 512 :: Int > showFloat alt left sign blank zero width prec num = -> unsafePerformIO ( do +> unsafePerformIO $ do + +#if __GLASGOW_HASKELL__ < 500 + > buf <- malloc bUFSIZE > snprintf buf (fromIntegral bUFSIZE) (packString format) num > let s = unpackCString buf @@ -38,8 +40,15 @@ > -- but that's just too heavyweight. > free buf > return s -> ) -> + +#else + +> allocaBytes bUFSIZE $ \buf -> do +> snprintf buf (fromIntegral bUFSIZE) (packString format) num +> peekCString buf + +#endif + > where > format = '%' : > if_bool alt "#" ++ @@ -61,4 +70,13 @@ > if_maybe (Just s) f = f s > type PackedString = ByteArray Int + +#if __GLASGOW_HASKELL__ < 500 + > foreign import unsafe snprintf :: Addr -> CSize -> PackedString -> Float -> IO () + +#else + +> foreign import unsafe snprintf :: CString -> CSize -> PackedString -> Float -> IO () + +#endif |