Browse Source

2004-04-06 Atsushi Enomoto <[email protected]>

	* DTDReader.cs : In ProcessDTDSubset(), 1)error message was
	  generated with incorrect stream character, 2)entity nest check
	  should not depend on line info which might not be supplied, 3)
	  empty PE should be skipped.
	* XmlParserInput.cs : use index for StringBuilder instead of calling
	  Remove() many times. This highly optimizes DTD parser.

	* XmlAttribute.cs : removed commented code.
	* XmlEntity.cs : removed unused field.

svn path=/trunk/mcs/; revision=25070
Atsushi Eno 22 years ago
parent
commit
865fccec0d

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

@@ -1,3 +1,15 @@
+2004-04-06  Atsushi Enomoto <[email protected]>
+
+	* DTDReader.cs : In ProcessDTDSubset(), 1)error message was 
+	  generated with incorrect stream character, 2)entity nest check 
+	  should not depend on line info which might not be supplied, 3)
+	  empty PE should be skipped.
+	* XmlParserInput.cs : use index for StringBuilder instead of calling
+	  Remove() many times. This highly optimizes DTD parser.
+
+	* XmlAttribute.cs : removed commented code.
+	* XmlEntity.cs : removed unused field.
+
 2004-04-05  Atsushi Enomoto <[email protected]>
 
 	* DTDObjectModel.cs : (DTDAttributeDefinition) create ArrayList 

+ 17 - 11
mcs/class/System.XML/System.Xml/DTDReader.cs

@@ -5,6 +5,7 @@
 //   Atsushi Enomoto  ([email protected])
 //
 // (C)2003 Atsushi Enomoto
+// (C)2004 Novell Inc.
 //
 // FIXME:
 //	When a parameter entity contains cp section, it should be closed 
@@ -170,7 +171,8 @@ namespace System.Xml
 		private bool ProcessDTDSubset ()
 		{
 			SkipWhitespace ();
-			switch(ReadChar ())
+			int c2 = ReadChar ();
+			switch(c2)
 			{
 			case -1:
 				return false;
@@ -180,17 +182,21 @@ namespace System.Xml
 					DTD.InternalSubsetHasPEReference = true;
 				string peName = ReadName ();
 				Expect (';');
-				currentInput.InsertParameterEntityBuffer (" ");
-				currentInput.InsertParameterEntityBuffer (GetPEValue (peName));
-				currentInput.InsertParameterEntityBuffer (" ");
-				int currentLine = currentInput.LineNumber;
-				int currentColumn = currentInput.LinePosition;
+				string peValue = GetPEValue (peName);
+				if (peValue == String.Empty)
+					break;
+				currentInput.InsertParameterEntityBuffer (peValue);
+//				int currentLine = currentInput.LineNumber;
+//				int currentColumn = currentInput.LinePosition;
 				while (currentInput.HasPEBuffer)
 					ProcessDTDSubset ();
-				if (currentInput.LineNumber != currentLine ||
-					currentInput.LinePosition != currentColumn)
-					throw new XmlException (this as IXmlLineInfo,
-						"Incorrectly nested parameter entity.");
+				SkipWhitespace ();
+				// FIXME: Implement correct nest-level check.
+				// Don't depend on lineinfo (might not be supplied)
+//				if (currentInput.LineNumber != currentLine ||
+//					currentInput.LinePosition != currentColumn)
+//					throw new XmlException (this as IXmlLineInfo,
+//						"Incorrectly nested parameter entity.");
 				break;
 			case '<':
 				int c = ReadChar ();
@@ -218,7 +224,7 @@ namespace System.Xml
 				SkipWhitespace ();
 				break;
 			default:
-				throw new XmlException (this as IXmlLineInfo,String.Format ("Syntax Error inside doctypedecl markup : {0}({1})", PeekChar (), (char) PeekChar ()));
+				throw new XmlException (this as IXmlLineInfo,String.Format ("Syntax Error inside doctypedecl markup : {0}({1})", c2, (char) c2));
 			}
 			currentInput.InitialState = false;
 			return true;

+ 1 - 13
mcs/class/System.XML/System.Xml/XmlAttribute.cs

@@ -208,19 +208,7 @@ namespace System.Xml
 		}
 
 		public override string Value {
-			get {
-				/*
-				switch (ChildNodes.Count) {
-				case 0:
-					return String.Empty;
-				case 1:
-					return FirstChild.Value;
-				default:
-					return BuildChildValue (ChildNodes);
-				}
-				*/
-				return BuildChildValue (ChildNodes);
-			}
+			get { return BuildChildValue (ChildNodes); }
 
 			set {
 				XmlNode firstChild = FirstChild;

+ 0 - 1
mcs/class/System.XML/System.Xml/XmlEntity.cs

@@ -36,7 +36,6 @@ namespace System.Xml
 		string publicId;
 		string systemId;
 		string baseUri;
-		XmlLinkedNode lastChild;
 
 		#endregion
 

+ 13 - 13
mcs/class/System.XML/System.Xml/XmlParserInput.cs

@@ -68,14 +68,16 @@ namespace Mono.Xml.Native
 
 		public void InsertParameterEntityBuffer (string value)
 		{
-			this.peBuffer.Insert (0, ' ' + value + ' ');
+			this.peBuffer.Insert (peBufferIndex, ' ');
+			this.peBuffer.Insert (peBufferIndex + 1, value);
+			this.peBuffer.Insert (peBufferIndex + value.Length + 1, ' ');
 			peStored = true;
 		}
 
 		public int PeekChar ()
 		{
 			if (peStored)
-				return peBuffer [0];
+				return peBuffer [peBufferIndex];
 
 			if (has_peek)
 				return peek_char;
@@ -95,9 +97,13 @@ namespace Mono.Xml.Native
 			int ch;
 
 			if (peStored) {
-				ch = peBuffer [0];
-				peBuffer.Remove (0, 1);
-				peStored = peBuffer.Length > 0;
+				ch = peBuffer [peBufferIndex];
+				peBufferIndex++;
+				if (peBufferIndex == peBuffer.Length) {
+					peStored = false;
+					peBuffer.Length = 0;
+					peBufferIndex = 0;
+				}
 				// I decided not to add character to currentTag with respect to PERef value
 				return ch;
 			}
@@ -131,14 +137,7 @@ namespace Mono.Xml.Native
 		}
 
 		public bool HasPEBuffer {
-			get {
-				if (!peStored)
-					return false;
-				else if (peBuffer.ToString ().Trim (XmlChar.WhitespaceChars).Length == 0)
-					return false;
-				else
-					return true;
-			}
+			get { return peStored; }
 		}
 		
 		public int LineNumber {
@@ -167,6 +166,7 @@ namespace Mono.Xml.Native
 		string baseURI;
 		bool peStored = false;
 		bool initialState = true;
+		int peBufferIndex;
 
 		private int ParseCharReference (string name)
 		{