shithub: mc

Download patch

ref: eac78a0fb1f780b2de3139fda214da9a26811fe3
parent: 56b0a563b067269bb530d7684e01d7feef06266b
author: Ori Bernstein <[email protected]>
date: Mon Oct 6 13:14:52 EDT 2014

Flush file correctly when closing.

--- a/bio.myr
+++ b/bio.myr
@@ -130,11 +130,11 @@
 
 /* closes a file, flushing it to the output fd */
 const close = {f
-	var closed
+	var fd
 
-	closed = (std.close(f.fd) == 0)
+	fd = f.fd
 	free(f)
-	-> closed
+	-> std.close(fd) == 0
 }
 
 const free = {f
--- a/test/bio-write.myr
+++ b/test/bio-write.myr
@@ -11,7 +11,7 @@
 	| `std.Some bio:	f = bio
 	| `std.None:	std.fatal(1, "Unable to open data file")
 	;;
-	
+
 	/* write a 5 byte chunk */
 	bio.write(f, "test\n")
 
@@ -23,9 +23,10 @@
 		buf[i] = 0x31
 	;;
 	bio.write(f, buf[:])
-	
+
 	/* final message after a big burst */
 	bio.write(f, "goodbye\n")
+	bio.flush(f)
 
 	/* and test for flush on close */
 	bio.close(f);