You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@apache.org on 2002/11/19 23:50:16 UTC

cvs commit: xml-xalan/c/src/XMLSupport FormatterToHTML.cpp FormatterToHTML.hpp FormatterToXML.cpp FormatterToXML.hpp

dbertoni    2002/11/19 14:50:16

  Modified:    c/src/XMLSupport FormatterToHTML.cpp FormatterToHTML.hpp
                        FormatterToXML.cpp FormatterToXML.hpp
  Log:
  More efficient fix for bug 13906.
  
  Revision  Changes    Path
  1.78      +22 -18    xml-xalan/c/src/XMLSupport/FormatterToHTML.cpp
  
  Index: FormatterToHTML.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XMLSupport/FormatterToHTML.cpp,v
  retrieving revision 1.77
  retrieving revision 1.78
  diff -u -r1.77 -r1.78
  --- FormatterToHTML.cpp	19 Nov 2002 17:10:50 -0000	1.77
  +++ FormatterToHTML.cpp	19 Nov 2002 22:50:15 -0000	1.78
  @@ -746,13 +746,13 @@
   
   
   void
  -FormatterToHTML::writeAttrString(const XalanDOMChar*	theString)
  +FormatterToHTML::writeAttrString(
  +			const XalanDOMChar*			theString,
  +			XalanDOMString::size_type	theStringLength)
   {
   	assert(theString != 0);
   
  -    const XalanDOMString::size_type		theLength = length(theString);
  -
  -    for (XalanDOMString::size_type i = 0;  i < theLength;  i ++)
  +    for (XalanDOMString::size_type i = 0;  i < theStringLength;  i ++)
       {
   		const XalanDOMChar	ch = theString[i];
   
  @@ -761,12 +761,12 @@
   			accumContent(ch);
   		}
   		else if(XalanUnicode::charAmpersand == ch &&
  -				i + 1 < theLength &&
  +				i + 1 < theStringLength &&
   				XalanUnicode::charLeftCurlyBracket == theString[i + 1])
   		{
   			accumContent(ch); // no escaping in this case, as specified in 15.2
   		}
  -		else if (accumDefaultEntity(ch, i, theString, theLength, true) == false)
  +		else if (accumDefaultEntity(ch, i, theString, theStringLength, true) == false)
   		{
   			if (0xd800 <= ch && ch < 0xdc00) 
   			{
  @@ -774,7 +774,7 @@
   
   				XalanDOMChar	next = 0;
   
  -				if (i + 1 >= theLength) 
  +				if (i + 1 >= theStringLength) 
   				{
   					throwInvalidUTF16SurrogateException(ch);
   				}
  @@ -855,28 +855,32 @@
   	// here...
   	// $$$ ToDo: It would be better if we didn't have to do
   	// this here.
  -	if (equals(name, DOMServices::s_XMLNamespacePrefix) == false)
  +	const XalanDOMString::size_type		nameLength = length(name);
  +
  +	if (equals(name, nameLength, c_wstr(DOMServices::s_XMLNamespacePrefix), DOMServices::s_XMLNamespacePrefixLength) == false)
   	{
   		accumContent(XalanUnicode::charSpace);
   
  -		if((length(value) == 0 || equalsIgnoreCaseASCII(name, value)) &&
  +		const XalanDOMString::size_type		valueLength = length(value);
  +
  +		if((valueLength == 0 || equalsIgnoreCaseASCII(name, nameLength, value, valueLength)) &&
   		   elemProperties.isAttribute(name, XalanHTMLElementsProperties::ATTREMPTY) == true)
   		{
   			accumName(name);
   		}
   		else
   		{
  -			accumName(name);
  +			accumName(name, 0, nameLength);
   			accumContent(XalanUnicode::charEqualsSign);
   			accumContent(XalanUnicode::charQuoteMark);
   
   			if(elemProperties.isAttribute(name, XalanHTMLElementsProperties::ATTRURL) == true)
   			{
  -				writeAttrURI(value);
  +				writeAttrURI(value, valueLength);
   			}
   			else
   			{
  -				writeAttrString(value);
  +				writeAttrString(value, valueLength);
   			}
   
   			accumContent(XalanUnicode::charQuoteMark);
  @@ -887,7 +891,9 @@
   
   
   void
  -FormatterToHTML::writeAttrURI(const XalanDOMChar*	theString)
  +FormatterToHTML::writeAttrURI(
  +			const XalanDOMChar*			theString,
  +			XalanDOMString::size_type	theStringLength)
   {
   	assert(theString != 0);
   
  @@ -906,9 +912,7 @@
   	// causing damage.	If the URL is already properly escaped, in theory, this 
   	// function should not change the string value.
   
  -	const XalanDOMString::size_type		len = length(theString);
  -
  -    for (XalanDOMString::size_type i = 0; i < len; ++i)
  +    for (XalanDOMString::size_type i = 0; i < theStringLength; ++i)
       {
   		const XalanDOMChar	ch = theString[i];
   
  @@ -1029,12 +1033,12 @@
   			}
   			else
   			{
  -				accumDefaultEntity(ch, i, theString, len, true);
  +				accumDefaultEntity(ch, i, theString, theStringLength, true);
   			}
   		}
   		else if (ch == XalanUnicode::charAmpersand)
   		{
  -			accumDefaultEntity(ch, i, theString, len, true);
  +			accumDefaultEntity(ch, i, theString, theStringLength, true);
   		}
   		else
   		{
  
  
  
  1.36      +8 -3      xml-xalan/c/src/XMLSupport/FormatterToHTML.hpp
  
  Index: FormatterToHTML.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XMLSupport/FormatterToHTML.hpp,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- FormatterToHTML.hpp	5 Sep 2002 07:09:23 -0000	1.35
  +++ FormatterToHTML.hpp	19 Nov 2002 22:50:16 -0000	1.36
  @@ -197,7 +197,9 @@
   protected:
   
   	virtual void
  -	writeAttrString(const XalanDOMChar*		theString);
  +	writeAttrString(
  +			const XalanDOMChar*			theString,
  +			XalanDOMString::size_type	theStringLength);
   
   	virtual void
   	accumCommentData(const XalanDOMChar*	data);
  @@ -291,10 +293,13 @@
   	 * Write the specified string after substituting non ASCII characters,
   	 * with %HH, where HH is the hex of the byte value.
   	 *
  -	 * @param   theString     String to convert to XML format.
  +	 * @param theString String to convert to HTML format.
  +	 * @param theStringLength The length of the string.
   	 */
   	void
  -	writeAttrURI(const XalanDOMChar*	theString);
  +	writeAttrURI(
  +			const XalanDOMChar*			theString,
  +			XalanDOMString::size_type	theStringLength);
   
   	/**
   	 * Accumulate the specified character by converting its numeric value to
  
  
  
  1.63      +6 -6      xml-xalan/c/src/XMLSupport/FormatterToXML.cpp
  
  Index: FormatterToXML.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XMLSupport/FormatterToXML.cpp,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- FormatterToXML.cpp	19 Nov 2002 17:10:51 -0000	1.62
  +++ FormatterToXML.cpp	19 Nov 2002 22:50:16 -0000	1.63
  @@ -1201,11 +1201,11 @@
   
   
   void
  -FormatterToXML::writeAttrString(const XalanDOMChar*		theString)
  +FormatterToXML::writeAttrString(
  +			const XalanDOMChar*			theString,
  +			XalanDOMString::size_type	theStringLength)
   {
  -    const XalanDOMString::size_type		len = length(theString);
  -
  -    for (XalanDOMString::size_type i = 0;  i < len;  i ++) 
  +    for (XalanDOMString::size_type i = 0;  i < theStringLength;  i ++) 
       {
   		const XalanDOMChar	ch = theString[i];
   
  @@ -1213,7 +1213,7 @@
   		    m_attrCharsMap[ch] == 'S') ||
   			ch > m_maxCharacter)
   		{
  -			accumDefaultEscape(ch, i, theString, len, true);
  +			accumDefaultEscape(ch, i, theString, theStringLength, true);
   		}
   		else
   		{
  @@ -1634,7 +1634,7 @@
   		accumName(name);
   		accumContent(XalanUnicode::charEqualsSign);
   		accumContent(XalanUnicode::charQuoteMark);
  -		writeAttrString(value);
  +		writeAttrString(value, length(value));
   		accumContent(XalanUnicode::charQuoteMark);
   	}
   }
  
  
  
  1.38      +5 -1      xml-xalan/c/src/XMLSupport/FormatterToXML.hpp
  
  Index: FormatterToXML.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XMLSupport/FormatterToXML.hpp,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- FormatterToXML.hpp	5 Sep 2002 22:01:29 -0000	1.37
  +++ FormatterToXML.hpp	19 Nov 2002 22:50:16 -0000	1.38
  @@ -575,10 +575,14 @@
   
   	/**
   	 * Write an attribute string.
  +	 *
   	 * @param theString The string to write.
  +	 * @param theStringLength The length of the string.
   	 */
   	virtual void
  -	writeAttrString(const XalanDOMChar*		theString);
  +	writeAttrString(
  +			const XalanDOMChar*			theString,
  +			XalanDOMString::size_type	theStringLength);
   
   	/**
   	 * Write the data for a comment
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org