diff options
author | simonmar <unknown> | 2000-09-25 10:51:04 +0000 |
---|---|---|
committer | simonmar <unknown> | 2000-09-25 10:51:04 +0000 |
commit | 63db52f1ae5f9d50cf9481c5de1f3ee109f642a5 (patch) | |
tree | a691f0a0f5d29940d344df58282702c9775ae806 /ghc/lib/std/cbits/flushFile.c | |
parent | 8ac8460237e85049ef2fde1b7e115fa1b52cd378 (diff) | |
download | haskell-63db52f1ae5f9d50cf9481c5de1f3ee109f642a5.tar.gz |
[project @ 2000-09-25 10:51:04 by simonmar]
Make flushFile and flushBuffer consistent. This code looked wrong
before, and it looks more correct now.
I can't see any need for flushFile at all.
flushBuffer still doesn't do the lseek thing that flushReadBuffer
does.
Diffstat (limited to 'ghc/lib/std/cbits/flushFile.c')
-rw-r--r-- | ghc/lib/std/cbits/flushFile.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/ghc/lib/std/cbits/flushFile.c b/ghc/lib/std/cbits/flushFile.c index 5631f38f95..496e881b57 100644 --- a/ghc/lib/std/cbits/flushFile.c +++ b/ghc/lib/std/cbits/flushFile.c @@ -1,7 +1,7 @@ /* * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998 * - * $Id: flushFile.c,v 1.7 2000/04/12 17:33:16 simonmar Exp $ + * $Id: flushFile.c,v 1.8 2000/09/25 10:51:04 simonmar Exp $ * * hFlush Runtime Support */ @@ -15,8 +15,9 @@ flushFile(StgForeignPtr ptr) IOFileObject* fo = (IOFileObject*)ptr; int rc = 0; - if ( (fo->flags & FILEOBJ_WRITE) && FILEOBJ_NEEDS_FLUSHING(fo) ) { - rc = writeBuffer(ptr,fo->bufWPtr - fo->bufRPtr); + if ( FILEOBJ_WRITEABLE(fo) && FILEOBJ_JUST_WRITTEN(fo) && + FILEOBJ_NEEDS_FLUSHING(fo) ) { + rc = writeBuffer(ptr, fo->bufWPtr - fo->bufRPtr); } return rc; @@ -28,14 +29,10 @@ flushBuffer(StgForeignPtr ptr) IOFileObject* fo = (IOFileObject*)ptr; int rc = 0; - /* If the file object is writeable, or if it's - RW *and* the last operation on it was a write, - flush it. - */ - if ( (!FILEOBJ_READABLE(fo) && FILEOBJ_WRITEABLE(fo)) || - (FILEOBJ_RW(fo) && FILEOBJ_JUST_WRITTEN(fo)) ) { - rc = flushFile(ptr); - if (rc<0) return rc; + if ( FILEOBJ_WRITEABLE(fo) && FILEOBJ_JUST_WRITTEN(fo) && + FILEOBJ_NEEDS_FLUSHING(fo) ) { + rc = writeBuffer(ptr, fo->bufWPtr - fo->bufRPtr); + if (rc<0) return rc; } /* TODO: shouldn't we do the lseek stuff from flushReadBuffer |