소스 검색

2002-03-24 Mike Kestner <[email protected]>

	* StreamReader.cs (ReadBuffer): Fix buffer merging bugs.

svn path=/trunk/mcs/; revision=3301
Mike Kestner 24 년 전
부모
커밋
aadd814550
2개의 변경된 파일7개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 0
      mcs/class/corlib/System.IO/ChangeLog
  2. 3 3
      mcs/class/corlib/System.IO/StreamReader.cs

+ 4 - 0
mcs/class/corlib/System.IO/ChangeLog

@@ -1,3 +1,7 @@
+2002-03-24  Mike Kestner <[email protected]>
+
+	* StreamReader.cs (ReadBuffer): Fix buffer merging bugs.
+
 2002-03-23  Martin Baulig  <[email protected]>
 
 	* StreamReader.cs: Always do buffered reading, use 4k blocks.

+ 3 - 3
mcs/class/corlib/System.IO/StreamReader.cs

@@ -130,7 +130,7 @@ namespace System.IO {
 		private bool ReadBuffer (int count)
 		{
 			// There are still enough bytes in the buffer.
-			if ((buffer != null) && (pos + count < buffer.Length))
+			if ((buffer != null) && (pos + count <= buffer.Length))
 				return true;
 
 			// Number of bytes remaining in the buffer.
@@ -147,11 +147,11 @@ namespace System.IO {
 			int bufcnt = decoder.GetCharCount (bytes, 0, cnt);
 			char[] newbuffer = new char [remaining + bufcnt];
 			if (remaining > 0)
-				Array.Copy (buffer, newbuffer, remaining);
+				Array.Copy (buffer, pos, newbuffer, 0, remaining);
 			buffer = newbuffer;
 
 			bufcnt = decoder.GetChars (bytes, 0, cnt, buffer, remaining);
-			pos = remaining;
+			pos = 0;
 
 			return true;
 		}