summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ab73ca6)
The foreign declaration for snprintf was wrong, because we need to
give the type of the C function after applying C's type promotion
rules. Hence the Float argument should be a Double, because it
occurs in the vararg section of the function type.
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
--- $Id: Printf.lhs,v 1.4 2001/08/13 10:27:27 simonmar Exp $
+-- $Id: Printf.lhs,v 1.5 2002/03/14 17:09:46 simonmar Exp $
-- (c) Simon Marlow 1997-2001
-----------------------------------------------------------------------------
-- (c) Simon Marlow 1997-2001
-----------------------------------------------------------------------------
#if __GLASGOW_HASKELL__ < 500
> buf <- malloc bUFSIZE
#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
> let s = unpackCString buf
> length s `seq` -- urk! need to force the string before we
> -- free the buffer. A better solution would
> allocaBytes bUFSIZE $ \buf ->
> withCString format $ \cformat -> do
> allocaBytes bUFSIZE $ \buf ->
> withCString format $ \cformat -> do
-> snprintf buf (fromIntegral bUFSIZE) cformat num
+> snprintf buf (fromIntegral bUFSIZE) cformat
+> (realToFrac num)
#if __GLASGOW_HASKELL__ < 500
> type PackedString = ByteArray Int
#if __GLASGOW_HASKELL__ < 500
> type PackedString = ByteArray Int
-> foreign import unsafe snprintf :: Addr -> CSize -> PackedString -> Float -> IO ()
+> foreign import unsafe snprintf :: Addr -> CSize -> PackedString -> Double -> IO ()
-> foreign import unsafe snprintf :: CString -> CSize -> CString -> Float -> IO ()
+> foreign import unsafe snprintf :: CString -> CSize -> CString -> Double -> IO ()