X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Futils%2FStringBuffer.lhs;h=e02a3ba0d5e2a1cc35d3ff459f5705b183968c6b;hb=f0d0e9d63ee27a12e80b6f069be5e9d4b55ca545;hp=a1eddb0280fd099d03174b426cb9929b6670f381;hpb=8226f00b071ea156753324dc9f2967dabc3cc571;p=ghc-hetmet.git diff --git a/compiler/utils/StringBuffer.lhs b/compiler/utils/StringBuffer.lhs index a1eddb0..e02a3ba 100644 --- a/compiler/utils/StringBuffer.lhs +++ b/compiler/utils/StringBuffer.lhs @@ -33,7 +33,7 @@ module StringBuffer lexemeToFastString, -- * Parsing integers - parseInteger, + parseUnsignedInteger, ) where #include "HsVersions.h" @@ -45,7 +45,6 @@ import Foreign import System.IO ( hGetBuf, hFileSize,IOMode(ReadMode), hClose , Handle, hTell ) -import GHC.Ptr ( Ptr(..) ) import GHC.Exts import GHC.IOBase ( IO(..) ) import GHC.Base ( unsafeChr ) @@ -114,7 +113,7 @@ hGetStringBufferBlock handle wanted withForeignPtr buf $ \ptr -> do r <- if size == 0 then return 0 else hGetBuf handle ptr size if r /= size - then ioError (userError $ "short read of file: "++show(r,size,fromIntegral size_i,handle)) + then ioError (userError $ "short read of file: "++show(r,size,size_i,handle)) else do pokeArray (ptr `plusPtr` size :: Ptr Word8) [0,0,0] return (StringBuffer buf size 0) @@ -208,8 +207,8 @@ byteOff (StringBuffer buf _ cur) i = return (unsafeChr (fromIntegral (w::Word8))) -- | XXX assumes ASCII digits only (by using byteOff) -parseInteger :: StringBuffer -> Int -> Integer -> (Char->Int) -> Integer -parseInteger buf len radix char_to_int +parseUnsignedInteger :: StringBuffer -> Int -> Integer -> (Char->Int) -> Integer +parseUnsignedInteger buf len radix char_to_int = go 0 0 where go i x | i == len = x @@ -224,19 +223,4 @@ parseInteger buf len radix char_to_int inlinePerformIO :: IO a -> a inlinePerformIO (IO m) = case m realWorld# of (# _, r #) -> r -#if __GLASGOW_HASKELL__ < 600 -mallocForeignPtrArray :: Storable a => Int -> IO (ForeignPtr a) -mallocForeignPtrArray = doMalloc undefined - where - doMalloc :: Storable b => b -> Int -> IO (ForeignPtr b) - doMalloc dummy size = mallocForeignPtrBytes (size * sizeOf dummy) - -mallocForeignPtrBytes :: Int -> IO (ForeignPtr a) -mallocForeignPtrBytes n = do - r <- mallocBytes n - newForeignPtr r (finalizerFree r) - -foreign import ccall unsafe "stdlib.h free" - finalizerFree :: Ptr a -> IO () -#endif \end{code}