[project @ 2001-08-07 11:13:46 by simonmar]
authorsimonmar <unknown>
Tue, 7 Aug 2001 11:13:46 +0000 (11:13 +0000)
committersimonmar <unknown>
Tue, 7 Aug 2001 11:13:46 +0000 (11:13 +0000)
Make this compile with newer GHCs.

glafp-utils/nofib-analyse/Printf.lhs

index 8d65c0c..feeea80 100644 (file)
@@ -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
 > 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
 >                             -- 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   "#" ++
 > 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