[various library fixes, added minusPtr, openBinaryFile, hGetLine, fixed type for C finalizers
John Meacham <john@repetae.net>**20090227142545
 Ignore-this: a67c83675bf1ed9299a6502e57c4839a
] hunk ./data/primitives.txt 34
+Foreign.C.Types.CULong, ubits<ptr>, int, UINTPTR_MAX, 0
hunk ./lib/base/Control/Exception.hs 14
+assert :: Bool -> a -> a
+assert True x = x
+assert False _ = error "assertion failure"
+
hunk ./lib/base/Foreign/ForeignPtr.hs 15
-type FinalizerPtr  a = Ptr a
+type FinalizerPtr  a = FunPtr (Ptr a -> IO ())
hunk ./lib/base/Foreign/Marshal/Alloc.hs 139
+-- | A pointer to a foreign function equivalent to 'free', which may be
+-- used as a finalizer (cf 'Foreign.ForeignPtr.ForeignPtr') for storage
+-- allocated with 'malloc', 'mallocBytes', 'realloc' or 'reallocBytes'.
+foreign import ccall unsafe "stdlib.h &free" finalizerFree :: FunPtr (Ptr a -> IO ())
+
+
+
hunk ./lib/base/Foreign/Ptr.hs 39
-minusPtr :: Ptr a -> Int -> Ptr b
-minusPtr (Ptr addr) off = Ptr (plusAddr addr (negate off))
+minusPtr :: Ptr a -> Ptr b -> Int
+minusPtr (Ptr a1) (Ptr a2) =  minusAddr a1 a2
hunk ./lib/base/Jhc/Addr.hs 16
+    minusAddr,
hunk ./lib/base/Jhc/Addr.hs 52
+{-# INLINE minusAddr #-}
+minusAddr :: Addr -> Addr -> Int
+minusAddr (Addr a1) (Addr a2) = boxInt (ptrToInt__ (a1 `minusWP` a2))
+
hunk ./lib/base/Jhc/Addr.hs 62
+foreign import primitive "I2I" ptrToInt__ :: BitsPtr_ -> Int__
hunk ./lib/base/Jhc/Addr.hs 65
+foreign import primitive "Sub" minusWP :: BitsPtr_ -> BitsPtr_ -> BitsPtr_
hunk ./lib/base/Jhc/Handle.hs 11
+    openBinaryFile,
hunk ./lib/base/Jhc/Handle.hs 29
-    handleFile :: Ptr (Ptr Handle),
-    handleIOMode :: IOMode
+    handleFile :: !(Ptr (Ptr Handle)),
+    handleBinary :: !Bool,
+    handleIOMode :: !IOMode
hunk ./lib/base/Jhc/Handle.hs 83
-        return Handle { handleName = fp, handleIOMode = m, handleFile = pptr }
+        return Handle { handleBinary = False, handleName = fp, handleIOMode = m, handleFile = pptr }
+
+openBinaryFile :: FilePath -> IOMode -> IO Handle
+openBinaryFile fp m = do
+    h <- openFile fp m
+    return h { handleBinary = True }
hunk ./lib/base/System/IO.hs 16
+    hGetChar,
+    hGetLine,
hunk ./lib/base/System/IO.hs 25
+    openBinaryFile,
hunk ./lib/base/System/IO.hs 92
-hPrint h x    =  hPutStrLn h (show x)
+hPrint h x  =  hPutStrLn h (show x)
hunk ./lib/base/System/IO.hs 94
+hGetLine    :: Handle -> IO String
+hGetLine h  =  do c <- hGetChar h
+                  if c == '\n' then return "" else
+                    do s <- hGetLine h
+                       return (c:s)
+
+hGetChar :: Handle -> IO Char
+hGetChar h = withHandle h $ \ptr -> do
+    ch <- c_fgetwc ptr
+    case ch of
+        -1 -> fail "hGetChar: EOF"
+        _  -> return (unsafeChr ch)