# Patch created by krokas
# Date: Wed Aug 30 20:49:05 MSD 2006
# Repository: pnetlib
# Comments:
# 
#### End of Preamble ####

#### Patch data follows ####
Index: runtime/System/IO/BinaryReader.cs
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/runtime/System/IO/BinaryReader.cs,v
retrieving revision 1.8
diff -c -r1.8 BinaryReader.cs
*** runtime/System/IO/BinaryReader.cs	31 Aug 2005 09:22:46 -0000	1.8
--- runtime/System/IO/BinaryReader.cs	30 Aug 2006 16:48:57 -0000
***************
*** 158,164 ****
  				{
  					if(posn >= smallBuffer.Length)
  					{
! 						newBuffer = new byte [smallBuffer.Length + 16];
  						Array.Copy(smallBuffer, newBuffer, smallBuffer.Length);
  						smallBuffer = newBuffer;
  					}
--- 158,164 ----
  				{
  					if(posn >= smallBuffer.Length)
  					{
! 						newBuffer = new byte[posn + 16];
  						Array.Copy(smallBuffer, newBuffer, smallBuffer.Length);
  						smallBuffer = newBuffer;
  					}
***************
*** 170,176 ****
  					smallBuffer[posn++] = (byte)byteval;
  				}
  				while(decoder.GetChars(smallBuffer, 0, posn,
! 									   smallCharBuffer, 0) < 1);
  
  				// Return the character that we read to the caller.
  				return smallCharBuffer[0];
--- 170,176 ----
  					smallBuffer[posn++] = (byte)byteval;
  				}
  				while(decoder.GetChars(smallBuffer, 0, posn,
! 									   smallCharBuffer, 0) > 1);
  
  				// Return the character that we read to the caller.
  				return smallCharBuffer[0];
***************
*** 419,431 ****
  				}
  
  				buffer = new byte [count];
  
  				do
  				{
  					int num2 = Read(buffer, result, count);
  					if(num2 == 0)
  					{
! 						throw new EndOfStreamException(_("IO_ReadEndOfStream"));
  						break;
  					}
  					result += num2;
--- 419,432 ----
  				}
  
  				buffer = new byte [count];
+ 				int pos = 0;
  
  				do
  				{
  					int num2 = Read(buffer, result, count);
  					if(num2 == 0)
  					{
! 						/* EOF */
  						break;
  					}
  					result += num2;
***************
*** 439,448 ****
  					Array.Copy(buffer, newBuffer, result);
  					return newBuffer;
  				}
! 				else
! 				{
! 					return buffer;
! 				}
  			}
  
  	// Read a buffer of characters.
--- 440,446 ----
  					Array.Copy(buffer, newBuffer, result);
  					return newBuffer;
  				}
! 				return buffer;
  			}
  
  	// Read a buffer of characters.
Index: runtime/System/Text/UTF8Encoding.cs
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/runtime/System/Text/UTF8Encoding.cs,v
retrieving revision 1.10
diff -c -r1.10 UTF8Encoding.cs
*** runtime/System/Text/UTF8Encoding.cs	13 Aug 2003 00:40:37 -0000	1.10
--- runtime/System/Text/UTF8Encoding.cs	30 Aug 2006 16:48:58 -0000
***************
*** 28,34 ****
  {
  	// Magic number used by Windows for UTF-8.
  	internal const int UTF8_CODE_PAGE = 65001;
! 
  	// Internal state.
  	private bool emitIdentifier;
  	private bool throwOnInvalid;
--- 28,34 ----
  {
  	// Magic number used by Windows for UTF-8.
  	internal const int UTF8_CODE_PAGE = 65001;
! 	public static readonly char EscapeByte = '\u0000';
  	// Internal state.
  	private bool emitIdentifier;
  	private bool throwOnInvalid;
***************
*** 679,685 ****
  							leftSoFar = 1;
  							leftSize = 5;
  						}
! 						else if((ch & (uint)0xFC) == (uint)0xFC)
  						{
  							// Six-byte UTF-8 character.
  							leftBits = (ch & (uint)0x03);
--- 679,685 ----
  							leftSoFar = 1;
  							leftSize = 5;
  						}
! 						else if((ch & (uint)0xFE) == (uint)0xFC)
  						{
  							// Six-byte UTF-8 character.
  							leftBits = (ch & (uint)0x03);
#### End of Patch data ####
