Sfoglia il codice sorgente

2005-09-14 Atsushi Enomoto <[email protected]>

        in System.Xml:
        * XmlTextReader.cs : when there is a heading half of surrogate
        * at the
          end of read buffer, it didn't treat it as a surrogate.
          Fixed bug #76102.

        in Test/System.Xml:
        * XmlTextReaderTests.cs : added #76102 testcase.

        in Test/XmlFiles:
        * 76102.xml : added test for bug #76102.

        in Test/System.Xml/W3C:
        * Makefile: build fix.


svn path=/trunk/mcs/; revision=50050
Atsushi Eno 20 anni fa
parent
commit
c041318f2c

+ 6 - 0
mcs/class/System.XML/System.Xml/ChangeLog

@@ -1,3 +1,9 @@
+2005-09-14  Atsushi Enomoto <[email protected]>
+
+	* XmlTextReader.cs : when there is a heading half of surrogate at the
+	  end of read buffer, it didn't treat it as a surrogate.
+	  Fixed bug #76102.
+
 2005-09-14  Atsushi Enomoto <[email protected]>
 
 	* XmlTextWriter.cs : for surrogate pair, output character reference

+ 12 - 9
mcs/class/System.XML/System.Xml/XmlTextReader.cs

@@ -1084,9 +1084,9 @@ namespace System.Xml
 		private int PeekChar ()
 		{
 			if (peekCharsLength == peekCharsIndex) {
-				if (!ReadTextReader ())
+				if (!ReadTextReader (-1))
 					return -1;
-					return PeekChar ();
+				return PeekChar ();
 			}
 
 			char c = peekChars [peekCharsIndex];
@@ -1094,13 +1094,12 @@ namespace System.Xml
 				return -1;
 			if (!char.IsSurrogate (c))
 				return c;
-			if (peekCharsLength == peekCharsIndex+1) {
-				if (!ReadTextReader ())
+			if (peekCharsLength == peekCharsIndex + 1) {
+				if (!ReadTextReader (c))
 					//FIXME: copy MS.NET behaviour when unpaired surrogate found
-			return peekChars [peekCharsIndex];
-				return PeekChar ();
+					return c;
 			}
-            
+
 			char highhalfChar = peekChars [peekCharsIndex];
 			char lowhalfChar = peekChars [peekCharsIndex+1];
 
@@ -1132,10 +1131,14 @@ namespace System.Xml
 			return ch;
 		}
 
-		private bool ReadTextReader ()
+		private bool ReadTextReader (int remained)
 		{
 			peekCharsIndex = 0;
-			peekCharsLength = reader.Read (peekChars, 0, peekCharCapacity);
+			if (remained >= 0)
+				peekChars [0] = (char) remained;
+			int offset = remained >= 0 ? 1 : 0;
+			peekCharsLength = reader.Read (peekChars, offset,
+				peekCharCapacity - offset) + offset;
 			return (peekCharsLength != 0);
 		}
 

+ 4 - 0
mcs/class/System.XML/Test/System.Xml/ChangeLog

@@ -1,3 +1,7 @@
+2005-09-14  Atsushi Enomoto <[email protected]>
+
+	* XmlTextReaderTests.cs : added #76102 testcase.
+
 2005-09-14  Atsushi Enomoto <[email protected]>
 
 	* XmlTextWriterTests.cs : added #76095 testcase.

+ 4 - 0
mcs/class/System.XML/Test/System.Xml/W3C/ChangeLog

@@ -1,3 +1,7 @@
+2005-09-14  Atsushi Enomoto  <[email protected]>
+
+	* Makefile: build fix.
+
 2005-08-17  Atsushi Enomoto  <[email protected]>
 
 	* xmlconf.cs: we need error message to do real-world debugging.

+ 2 - 2
mcs/class/System.XML/Test/System.Xml/W3C/Makefile

@@ -3,7 +3,7 @@
 RUNTIME=mono
 XMLCONF_OPTIONS=
 CSCOMPILE=mcs
-REFERENCES=-d:NUNIT_SUPPORT -r:NUnit.Core -r:NUnit.Framework
+REFERENCES=-d:NUNIT_SUPPORT -r:nunit.core -r:nunit.framework
 TEST_ARCHIVE=xmlts20031210.zip
 TEST_CATALOG=xmlconf/xmlconf.xml
 TEST_PROG=xmlconf.dll
@@ -45,5 +45,5 @@ $(TEST_CATALOG): $(TEST_ARCHIVE)
 	touch $(TEST_CATALOG)
 
 .cs.dll:
-	$(CSCOMPILE) /t:library $< $(REFERENCES)
+	$(CSCOMPILE) /t:library /lib:$(nunit_MONO_PATH) $< $(REFERENCES)
 

+ 14 - 0
mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs

@@ -1115,5 +1115,19 @@ namespace MonoTests.System.Xml
 				XmlNodeType.Document, null);
 			xtr.Read ();
 		}
+
+		[Test] // bug #76102
+		public void SurrogateAtReaderByteCache ()
+		{
+			XmlTextReader xtr = null;
+			try {
+				xtr = new XmlTextReader (File.OpenText ("Test/XmlFiles/76102.xml"));
+				while (!xtr.EOF)
+					xtr.Read ();
+			} finally {
+				if (xtr != null)
+					xtr.Close ();
+			}
+		}
 	}
 }

+ 1 - 0
mcs/class/System.XML/Test/XmlFiles/76102.xml

@@ -0,0 +1 @@
+<a>************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************𐌹</a>

+ 4 - 0
mcs/class/System.XML/Test/XmlFiles/ChangeLog

@@ -1,3 +1,7 @@
+2005-09-14  Atsushi Enomoto <[email protected]>
+
+	* 76102.xml : added test for bug #76102.
+
 2004-09-06  Atsushi Enomoto <[email protected]>
 
 	* added simple.xml (to be used for some tests).