X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=glafp-utils%2Fnofib-analyse%2FPrintf.lhs;h=33b5290e074ca16abd6a547f536424832dfe82a2;hb=aa448d763b78da58196be4aa43113da2c7a35139;hp=feeea803cac0e28d8698b5d8f8b0d1ed04ad0670;hpb=f0bd52ecf6f6a16152ca826e4145da2ef3f0193e;p=ghc-hetmet.git diff --git a/glafp-utils/nofib-analyse/Printf.lhs b/glafp-utils/nofib-analyse/Printf.lhs index feeea80..33b5290 100644 --- a/glafp-utils/nofib-analyse/Printf.lhs +++ b/glafp-utils/nofib-analyse/Printf.lhs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: Printf.lhs,v 1.3 2001/08/07 11:13:46 simonmar Exp $ +-- $Id: Printf.lhs,v 1.5 2002/03/14 17:09:46 simonmar Exp $ -- (c) Simon Marlow 1997-2001 ----------------------------------------------------------------------------- @@ -32,7 +32,8 @@ #if __GLASGOW_HASKELL__ < 500 > buf <- malloc bUFSIZE -> snprintf buf (fromIntegral bUFSIZE) (packString format) num +> snprintf buf (fromIntegral bUFSIZE) (packString format) +> (realToFrac num) > let s = unpackCString buf > length s `seq` -- urk! need to force the string before we > -- free the buffer. A better solution would @@ -43,9 +44,11 @@ #else -> allocaBytes bUFSIZE $ \buf -> do -> snprintf buf (fromIntegral bUFSIZE) (packString format) num -> peekCString buf +> allocaBytes bUFSIZE $ \buf -> +> withCString format $ \cformat -> do +> snprintf buf (fromIntegral bUFSIZE) cformat +> (realToFrac num) +> peekCString buf #endif @@ -69,14 +72,13 @@ > if_maybe Nothing f = [] > if_maybe (Just s) f = f s -> type PackedString = ByteArray Int - #if __GLASGOW_HASKELL__ < 500 -> foreign import unsafe snprintf :: Addr -> CSize -> PackedString -> Float -> IO () +> type PackedString = ByteArray Int +> foreign import unsafe snprintf :: Addr -> CSize -> PackedString -> Double -> IO () #else -> foreign import unsafe snprintf :: CString -> CSize -> PackedString -> Float -> IO () +> foreign import unsafe snprintf :: CString -> CSize -> CString -> Double -> IO () #endif