From: Simon Marlow Date: Wed, 3 May 2006 10:35:04 +0000 (+0000) Subject: Fix string truncating in hGetLine -- it was a pasto from Simon's code X-Git-Tag: directory_2007-05-24~298 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=364b4996fbb46bc4c940db48c35497d87970ac4f;p=haskell-directory.git Fix string truncating in hGetLine -- it was a pasto from Simon's code (from Don Stewart) --- diff --git a/Data/ByteString.hs b/Data/ByteString.hs index 61ed887..6eb861a 100644 --- a/Data/ByteString.hs +++ b/Data/ByteString.hs @@ -238,6 +238,7 @@ import Data.Maybe (listToMaybe) import Data.Array (listArray) import qualified Data.Array as Array ((!)) +-- Control.Exception.bracket not available in yhc or nhc import Control.Exception (bracket) import Foreign.C.String (CString, CStringLen) @@ -247,6 +248,7 @@ import Foreign.Marshal.Array import Foreign.Ptr import Foreign.Storable (Storable(..)) +-- hGetBuf and hPutBuf not available in yhc or nhc import System.IO (stdin,stdout,hClose,hFileSize ,hGetBuf,hPutBuf,openBinaryFile ,Handle,IOMode(..)) @@ -1663,7 +1665,7 @@ hGetLine h = wantReadableHandle "Data.ByteString.hGetLine" h $ \ handle_ -> do mkPS :: RawBuffer -> Int -> Int -> IO ByteString mkPS buf start end = do let len = end - start - fp <- mallocByteString (len `quot` 8) + fp <- mallocByteString len withForeignPtr fp $ \p -> do memcpy_ptr_baoff p buf start (fromIntegral len) return (PS fp 0 len)