X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Flib%2Fmisc%2FCString.lhs;h=83712be70431743455af073daf19a18075b3c996;hb=94ac8915eb5ea8e47022d30405e5de0b88eb3f83;hp=48c1f55589b459629376214415bdd059ff44261d;hpb=a9d0fc543966edebf8f23c87982a826c8eb3d0c2;p=ghc-hetmet.git diff --git a/ghc/lib/misc/CString.lhs b/ghc/lib/misc/CString.lhs index 48c1f55..83712be 100644 --- a/ghc/lib/misc/CString.lhs +++ b/ghc/lib/misc/CString.lhs @@ -80,7 +80,7 @@ unpackCStringIO addr -- unpack 'len' chars unpackCStringLenIO :: Addr -> Int -> IO String unpackCStringLenIO addr l@(I# len#) - | len# <# 0# = fail (userError ("CString.unpackCStringLenIO: negative length (" ++ show l ++ ")")) + | len# <# 0# = ioError (userError ("CString.unpackCStringLenIO: negative length (" ++ show l ++ ")")) | len# ==# 0# = return "" | otherwise = unpack [] (len# -# 1#) where @@ -102,8 +102,8 @@ unpackNBytesBAIO ba l = unpackNBytesAccBAIO ba l [] -- note: no bounds checking! unpackNBytesAccBAIO :: ByteArray Int -> Int -> [Char] -> IO [Char] -unpackNBytesAccBAIO ba 0 rest = return rest -unpackNBytesAccBAIO (ByteArray _ ba) (I# len#) rest = unpack rest (len# -# 1#) +unpackNBytesAccBAIO _ 0 rest = return rest +unpackNBytesAccBAIO (ByteArray _ ba) (I# len#) rest = unpack rest (len# -# 1#) where unpack acc i# | i# <# 0# = return acc @@ -134,13 +134,13 @@ strings No indices...I hate indices. Death to Ix. \begin{code} vectorize :: [String] -> IO (ByteArray Int) -vectorize xs = do +vectorize vs = do arr <- allocWords (len + 1) - fill arr 0 xs + fill arr 0 vs freeze arr where len :: Int - len = length xs + len = length vs fill :: MutableByteArray RealWorld Int -> Int -> [String] -> IO () fill arr n [] =