[project @ 2003-04-23 10:27:53 by simonmar]
authorsimonmar <unknown>
Wed, 23 Apr 2003 10:27:53 +0000 (10:27 +0000)
committersimonmar <unknown>
Wed, 23 Apr 2003 10:27:53 +0000 (10:27 +0000)
hGetArray/hPutArray with a count argument of zero now just return
doing nothing.  This brings them into line with hGetBuf/hPutBuf and
fixes a bug in Data.PackedString.hPutPS which fails on an empty string.

Data/Array/IO.hs

index 34e9584..bc82e2d 100644 (file)
@@ -141,7 +141,9 @@ hGetArray
                -- if the end of file was reached.
 
 hGetArray handle (IOUArray (STUArray l u ptr)) count
-  | count <= 0 || count > rangeSize (l,u)
+  | count == 0
+  = return 0
+  | count < 0 || count > rangeSize (l,u)
   = illegalBufferSize handle "hGetArray" count
   | otherwise = do
       wantReadableHandle "hGetArray" handle $ 
@@ -191,7 +193,9 @@ hPutArray
        -> IO ()
 
 hPutArray handle (IOUArray (STUArray l u raw)) count
-  | count <= 0 || count > rangeSize (l,u)
+  | count == 0
+  = return ()
+  | count < 0 || count > rangeSize (l,u)
   = illegalBufferSize handle "hPutArray" count
   | otherwise
    = do wantWritableHandle "hPutArray" handle $