Author: miguel
Date: 2005-04-09 15:23:15 -0400 (Sat, 09 Apr 2005)
New Revision: 42738
Modified:
trunk/mcs/class/corlib/System.IO/ChangeLog
trunk/mcs/class/corlib/System.IO/StreamWriter.cs
trunk/mcs/class/corlib/Test/System.IO/ChangeLog
trunk/mcs/class/corlib/Test/System.IO/StreamWriterTest.cs
Log:
2005-04-09 Miguel de Icaza <[EMAIL PROTECTED]>
* StreamWriter.cs (Initialize): Avoid echoing the preamble to a
file if the position of the stream is not at the beginning. Fixes
bug #74513
2005-04-09 Miguel de Icaza <[EMAIL PROTECTED]>
* StreamWriterTest.cs: New test for bug #74513.
Modified: trunk/mcs/class/corlib/System.IO/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System.IO/ChangeLog 2005-04-09 18:48:44 UTC (rev
42737)
+++ trunk/mcs/class/corlib/System.IO/ChangeLog 2005-04-09 19:23:15 UTC (rev
42738)
@@ -1,3 +1,9 @@
+2005-04-09 Miguel de Icaza <[EMAIL PROTECTED]>
+
+ * StreamWriter.cs (Initialize): Avoid echoing the preamble to a
+ file if the position of the stream is not at the beginning. Fixes
+ bug #74513
+
2005-04-07 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* FileStream.cs:
Modified: trunk/mcs/class/corlib/System.IO/StreamWriter.cs
===================================================================
--- trunk/mcs/class/corlib/System.IO/StreamWriter.cs 2005-04-09 18:48:44 UTC
(rev 42737)
+++ trunk/mcs/class/corlib/System.IO/StreamWriter.cs 2005-04-09 19:23:15 UTC
(rev 42738)
@@ -72,6 +72,10 @@
int BufferSize = Math.Max(bufferSize,
MinimumBufferSize);
decode_buf = new char [BufferSize];
byte_buf = new byte [encoding.GetMaxByteCount
(BufferSize)];
+
+ // Fixes bug
http://bugzilla.ximian.com/show_bug.cgi?id=74513
+ if (internalStream.CanSeek && internalStream.Position >
0)
+ preamble_done = true;
}
//[MonoTODO("Nothing is done with bufferSize")]
Modified: trunk/mcs/class/corlib/Test/System.IO/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/System.IO/ChangeLog 2005-04-09 18:48:44 UTC
(rev 42737)
+++ trunk/mcs/class/corlib/Test/System.IO/ChangeLog 2005-04-09 19:23:15 UTC
(rev 42738)
@@ -1,3 +1,7 @@
+2005-04-09 Miguel de Icaza <[EMAIL PROTECTED]>
+
+ * StreamWriterTest.cs: New test for bug #74513.
+
2005-03-24 Sebastien Pouliot <[EMAIL PROTECTED]>
* DirectoryCas.cs: Added partial trust unit tests.
Modified: trunk/mcs/class/corlib/Test/System.IO/StreamWriterTest.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System.IO/StreamWriterTest.cs 2005-04-09
18:48:44 UTC (rev 42737)
+++ trunk/mcs/class/corlib/Test/System.IO/StreamWriterTest.cs 2005-04-09
19:23:15 UTC (rev 42738)
@@ -434,6 +434,23 @@
w.Write (s);
}
+ [Test]
+ public void NoPreambleOnAppend ()
+ {
+ MemoryStream ms = new MemoryStream ();
+ StreamWriter w = new StreamWriter (ms, Encoding.UTF8);
+ w.Write ("a");
+ w.Flush ();
+ AssertEquals ("Incorrect size after writing 1 byte plus
header", ms.Position, 4);
+
+ // Append 1 byte, should skip the preamble now.
+ w.Write ("a");
+ w.Flush ();
+ w = new StreamWriter (ms, Encoding.UTF8);
+ AssertEquals ("Incorrect size after writing 1 byte, must have
been 5", ms.Position, 5);
+
+ }
+
// TODO - Write - test errors, functionality tested in TestFlush.
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches