summaryrefslogtreecommitdiff
path: root/ghc/lib/std/cbits/closeFile.c
diff options
context:
space:
mode:
authorsimonmar <unknown>2000-09-25 10:48:50 +0000
committersimonmar <unknown>2000-09-25 10:48:50 +0000
commit8ac8460237e85049ef2fde1b7e115fa1b52cd378 (patch)
treeb00d1645262b9332cba1d34cb256bf3f81976c30 /ghc/lib/std/cbits/closeFile.c
parent01d54e8741ea99cfbeb96496b927be87d0657eac (diff)
downloadhaskell-8ac8460237e85049ef2fde1b7e115fa1b52cd378.tar.gz
[project @ 2000-09-25 10:48:50 by simonmar]
Don't blindly flush the buffer just because it is writeable. It might be a RW handle with a read buffer.
Diffstat (limited to 'ghc/lib/std/cbits/closeFile.c')
-rw-r--r--ghc/lib/std/cbits/closeFile.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/ghc/lib/std/cbits/closeFile.c b/ghc/lib/std/cbits/closeFile.c
index 3c3eb4ac4b..82fdc51062 100644
--- a/ghc/lib/std/cbits/closeFile.c
+++ b/ghc/lib/std/cbits/closeFile.c
@@ -1,7 +1,7 @@
/*
* (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
*
- * $Id: closeFile.c,v 1.9 2000/03/28 08:49:56 simonmar Exp $
+ * $Id: closeFile.c,v 1.10 2000/09/25 10:48:50 simonmar Exp $
*
* hClose Runtime Support
*/
@@ -32,8 +32,9 @@ closeFile(StgForeignPtr ptr, StgInt flush_buf)
return 0;
}
- if ( flush_buf != 0 && (fo->flags & FILEOBJ_WRITE) ) {
- writeFileObject(ptr,fo->bufWPtr);
+ /* Flush buffer if we have unwritten data */
+ if ( flush_buf != 0 ) {
+ flushBuffer(fo);
}
/* If the flush failed, we ignore this and soldier on.. */