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/17 01:48:06 UTC

cvs commit: xml-xalan/c/src/XercesParserLiaison XercesParserLiaison.cpp XercesParserLiaison.hpp

dbertoni    2002/11/16 16:48:06

  Modified:    c/src/XercesParserLiaison XercesParserLiaison.cpp
                        XercesParserLiaison.hpp
  Log:
  Fix for bug 14614.  Removed unnecessary insert of document into map.
  
  Revision  Changes    Path
  1.55      +38 -34    xml-xalan/c/src/XercesParserLiaison/XercesParserLiaison.cpp
  
  Index: XercesParserLiaison.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XercesParserLiaison/XercesParserLiaison.cpp,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- XercesParserLiaison.cpp	14 Nov 2002 23:55:56 -0000	1.54
  +++ XercesParserLiaison.cpp	17 Nov 2002 00:48:06 -0000	1.55
  @@ -10,33 +10,33 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *	  notice, this list of conditions and the following disclaimer. 
    *
    * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  + *	  notice, this list of conditions and the following disclaimer in
  + *	  the documentation and/or other materials provided with the
  + *	  distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowledgment may appear in the software itself,
  - *    if and wherever such third-party acknowledgments normally appear.
  + *	  if any, must include the following acknowledgment:  
  + *		 "This product includes software developed by the
  + *		  Apache Software Foundation (http://www.apache.org/)."
  + *	  Alternately, this acknowledgment may appear in the software itself,
  + *	  if and wherever such third-party acknowledgments normally appear.
    *
    * 4. The names "Xalan" and "Apache Software Foundation" must
  - *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  - *    permission, please contact apache@apache.org.
  + *	  not be used to endorse or promote products derived from this
  + *	  software without prior written permission. For written 
  + *	  permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  - *    nor may "Apache" appear in their name, without prior written
  - *    permission of the Apache Software Foundation.
  + *	  nor may "Apache" appear in their name, without prior written
  + *	  permission of the Apache Software Foundation.
    *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * DISCLAIMED.	IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  @@ -54,7 +54,6 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  -// Class header file.
   #include "XercesParserLiaison.hpp"
   
   
  @@ -156,7 +155,8 @@
   		i != m_documentMap.end();
   		++i)
   	{
  -		if ((*i).second.m_isDeprecated == false)
  +		if ((*i).second.m_isDeprecated == false &&
  +			(*i).second.m_isOwned == true)
   		{
   #if defined(XALAN_CANNOT_DELETE_CONST)
   			delete (DOMDocument*)(*i).second.m_wrapper->getXercesDocument();
  @@ -201,7 +201,7 @@
   			DocumentHandler&		handler,
   			const XalanDOMString&	/* identifier */)
   {
  -	XalanAutoPtr<SAXParser>		theParser(CreateSAXParser());
  +	XalanAutoPtr<SAXParser> 	theParser(CreateSAXParser());
   
   	theParser->setDocumentHandler(&handler);
   
  @@ -227,7 +227,7 @@
   #if XERCES_VERSION_MAJOR >= 2
   	XalanAutoPtr<XercesDOMParser>	theParser(CreateDOMParser());
   #else
  -	XalanAutoPtr<DOMParser>		theParser(CreateDOMParser());
  +	XalanAutoPtr<DOMParser> 	theParser(CreateDOMParser());
   #endif
   
   	if (m_errorHandler == 0)
  @@ -258,7 +258,7 @@
   
   	if (theXercesDocument != 0)
   	{
  -		theNewDocument = doCreateDocument(theXercesDocument, m_threadSafe, m_buildWrapper);
  +		theNewDocument = doCreateDocument(theXercesDocument, m_threadSafe, m_buildWrapper, true);
   
   		theParser->adoptDocument();
   #else
  @@ -266,10 +266,8 @@
   
   	if (theXercesDocument.isNull() == false)
   	{
  -		theNewDocument = doCreateDocument(theXercesDocument, m_threadSafe, m_buildBridge);
  +		theNewDocument = doCreateDocument(theXercesDocument, m_threadSafe, m_buildBridge, true);
   #endif
  -
  -		m_documentMap[theNewDocument] = theNewDocument;
   	}
   
   	return theNewDocument;
  @@ -297,7 +295,7 @@
   
   
   void
  -XercesParserLiaison::destroyDocument(XalanDocument*		theDocument)
  +XercesParserLiaison::destroyDocument(XalanDocument* 	theDocument)
   {
   	if (mapDocument(theDocument) != 0)
   	{
  @@ -358,7 +356,7 @@
   
   
   void
  -XercesParserLiaison::setIncludeIgnorableWhitespace(bool	include)
  +XercesParserLiaison::setIncludeIgnorableWhitespace(bool include)
   {
   	m_includeIgnorableWhitespace = include;
   }
  @@ -477,7 +475,7 @@
   
   XalanDocument*
   XercesParserLiaison::createDocument(
  -			const DOM_Document&		theXercesDocument,
  +			const DOM_Document& 	theXercesDocument,
   			bool					threadSafe,
   			bool					buildBridge)
   {
  @@ -492,7 +490,9 @@
   			bool				threadSafe,
   			bool				buildWrapper)
   {
  -	return doCreateDocument(theXercesDocument, threadSafe, buildWrapper);
  +	// As we did not create the underlying DOMDocument - ensure we don't
  +	// delete it later.
  +	return doCreateDocument(theXercesDocument, threadSafe, buildWrapper, false);
   }
   
   
  @@ -520,7 +520,7 @@
   
   
   DOM_Document
  -XercesParserLiaison::mapXercesDocument(const XalanDocument*		theDocument) const
  +XercesParserLiaison::mapXercesDocument(const XalanDocument* 	theDocument) const
   {
   	const DocumentMapType::const_iterator	i =
   		m_documentMap.find(theDocument);
  @@ -570,7 +570,7 @@
   
   
   void
  -XercesParserLiaison::error(const SAXParseException&		e)
  +XercesParserLiaison::error(const SAXParseException& 	e)
   {
   	XalanDOMString	theMessage("Error ");
   
  @@ -627,7 +627,7 @@
   void
   XercesParserLiaison::formatErrorMessage(
   			const SAXParseException&	e,
  -			XalanDOMString&				theMessage)
  +			XalanDOMString& 			theMessage)
   {
   	append(theMessage, " at (file ");
   
  @@ -727,11 +727,11 @@
   
   XercesDocumentBridge*
   XercesParserLiaison::doCreateDocument(
  -			const DOM_Document&		theXercesDocument,
  +			const DOM_Document& 	theXercesDocument,
   			bool					threadSafe,
   			bool					buildBridge)
   {
  -	XercesDocumentBridge* const		theNewDocument =
  +	XercesDocumentBridge* const 	theNewDocument =
   		new XercesDocumentBridge(theXercesDocument, threadSafe, buildBridge);
   
   	m_documentMap[theNewDocument] = theNewDocument;
  @@ -745,12 +745,16 @@
   XercesParserLiaison::doCreateDocument(
   			const DOMDocument*	theXercesDocument,
   			bool				threadSafe,
  -			bool				buildWrapper)
  +			bool				buildWrapper,
  +			bool				isOwned)
   {
   	XercesDocumentWrapper* const		theNewDocument =
   		new XercesDocumentWrapper(theXercesDocument, threadSafe, buildWrapper);
   
  -	m_documentMap[theNewDocument] = theNewDocument;
  +	DocumentEntry&	theEntry = m_documentMap[theNewDocument];
  +	
  +	theEntry = theNewDocument;
  +	theEntry.m_isOwned = isOwned;
   
   	return theNewDocument;
   }
  
  
  
  1.39      +13 -7     xml-xalan/c/src/XercesParserLiaison/XercesParserLiaison.hpp
  
  Index: XercesParserLiaison.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XercesParserLiaison/XercesParserLiaison.hpp,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- XercesParserLiaison.hpp	3 Oct 2002 07:05:59 -0000	1.38
  +++ XercesParserLiaison.hpp	17 Nov 2002 00:48:06 -0000	1.39
  @@ -359,7 +359,7 @@
   	 */
   	XalanDocument*
   	createDocument(
  -			const DOM_Document&		theXercesDocument,
  +			const DOM_Document& 	theXercesDocument,
   			bool					threadSafe,
   			bool					buildBridge);
   
  @@ -466,6 +466,7 @@
   	struct DocumentEntry
   	{
   		bool	m_isDeprecated;
  +		bool	m_isOwned;
   
   		union
   		{
  @@ -474,12 +475,14 @@
   		};
   
   		DocumentEntry&
  -		operator=(XercesDocumentBridge*		theBridge)
  +		operator=(XercesDocumentBridge* 	theBridge)
   		{
   			m_isDeprecated = true;
   
   			m_bridge = theBridge;
   
  +			m_isOwned = true;
  +
   			return *this;
   		}
   
  @@ -490,6 +493,8 @@
   
   			m_wrapper = theWrapper;
   
  +			m_isOwned = true;
  +
   			return *this;
   		}
   	};
  @@ -500,7 +505,7 @@
   				less<const XalanDocument*> >	DocumentMapType;
   #else
   	typedef std::map<const XalanDocument*,
  -					 DocumentEntry>				DocumentMapType;
  +					 DocumentEntry> 			DocumentMapType;
   #endif
   
   	/**
  @@ -611,7 +616,7 @@
   	}
   
   #if XERCES_VERSION_MAJOR >= 2
  -	typedef XercesDOMParser		DOMParserType;
  +	typedef XercesDOMParser 	DOMParserType;
   #else
   	typedef DOMParser	DOMParserType;
   #endif
  @@ -621,7 +626,7 @@
   	static void
   	formatErrorMessage(
   			const SAXParseException&	e,
  -			XalanDOMString&				theMessage);
  +			XalanDOMString& 			theMessage);
   
   	DOMParserType*
   	CreateDOMParser();
  @@ -639,7 +644,7 @@
   	 */
   	XercesDocumentBridge*
   	doCreateDocument(
  -			const DOM_Document&		theXercesDocument,
  +			const DOM_Document& 	theXercesDocument,
   			bool					threadSafe,
   			bool					buildBridge);
   
  @@ -655,7 +660,8 @@
   	doCreateDocument(
   			const DOMDocument*	theXercesDocument,
   			bool				threadSafe,
  -			bool				buildWrapper);
  +			bool				buildWrapper,
  +			bool				isOwned);
   
   private:
   
  
  
  

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