You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ca...@apache.org on 2005/06/21 17:48:07 UTC

svn commit: r191671 - in /xerces/c/branches/xerces-2.7/src/xercesc/parsers: SAX2XMLReaderImpl.cpp SAX2XMLReaderImpl.hpp SAXParser.cpp SAXParser.hpp

Author: cargilld
Date: Tue Jun 21 08:48:06 2005
New Revision: 191671

URL: http://svn.apache.org/viewcvs?rev=191671&view=rev
Log:
Add back changes Bertoni made that were overwritten.

Modified:
    xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAX2XMLReaderImpl.cpp
    xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAX2XMLReaderImpl.hpp
    xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAXParser.cpp
    xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAXParser.hpp

Modified: xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAX2XMLReaderImpl.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAX2XMLReaderImpl.cpp?rev=191671&r1=191670&r2=191671&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAX2XMLReaderImpl.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAX2XMLReaderImpl.cpp Tue Jun 21 08:48:06 2005
@@ -47,6 +47,12 @@
     chOpenSquare, chLatin_d, chLatin_t, chLatin_d, chCloseSquare, chNull
 };
 
+
+
+typedef JanitorMemFunCall<SAX2XMLReaderImpl>    CleanupType;
+typedef JanitorMemFunCall<SAX2XMLReaderImpl>    ResetInProgressType;
+
+
 SAX2XMLReaderImpl::SAX2XMLReaderImpl(MemoryManager* const  manager
                                    , XMLGrammarPool* const gramPool):
 
@@ -78,19 +84,22 @@
     , fMemoryManager(manager)
     , fGrammarPool(gramPool)
 {
+    CleanupType cleanup(this, &SAX2XMLReaderImpl::cleanUp);
+
     try
     {
         initialize();
     }
     catch(const OutOfMemoryException&)
     {
+        // Don't cleanup when out of memory, since executing the
+        // code can cause problems.
+        cleanup.release();
+
         throw;
     }
-    catch(...)
-    {
-        cleanUp();
-        throw;
-    }
+
+    cleanup.release();
 }
 
 SAX2XMLReaderImpl::~SAX2XMLReaderImpl()
@@ -379,19 +388,17 @@
     if (fParseInProgress)
         ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager);
 
+    ResetInProgressType     resetInProgress(this, &SAX2XMLReaderImpl::resetInProgress);
+
     try
     {
         fParseInProgress = true;
         fScanner->scanDocument(source);
-        fParseInProgress = false;
     }
     catch(const OutOfMemoryException&)
     {
-        throw;
-    }
-    catch (...)
-    {
-        fParseInProgress = false;
+        resetInProgress.release();
+
         throw;
     }
 }
@@ -402,19 +409,17 @@
     if (fParseInProgress)
         ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager);
 
+    ResetInProgressType     resetInProgress(this, &SAX2XMLReaderImpl::resetInProgress);
+
     try
     {
         fParseInProgress = true;
         fScanner->scanDocument(systemId);
-        fParseInProgress = false;
     }
     catch(const OutOfMemoryException&)
     {
-        throw;
-    }
-    catch (...)
-    {
-        fParseInProgress = false;
+        resetInProgress.release();
+
         throw;
     }
 }
@@ -425,6 +430,8 @@
     if (fParseInProgress)
         ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager);
 
+    ResetInProgressType     resetInProgress(this, &SAX2XMLReaderImpl::resetInProgress);
+
     try
     {
         fParseInProgress = true;
@@ -433,11 +440,8 @@
     }
     catch(const OutOfMemoryException&)
     {
-        throw;
-    }
-    catch (...)
-    {
-        fParseInProgress = false;
+        resetInProgress.release();
+
         throw;
     }
 }
@@ -1461,20 +1465,18 @@
     if (fParseInProgress)
         ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager);
 
+    ResetInProgressType     resetInProgress(this, &SAX2XMLReaderImpl::resetInProgress);
+
     Grammar* grammar = 0;
     try
     {
         fParseInProgress = true;
         grammar = fScanner->loadGrammar(systemId, grammarType, toCache);
-        fParseInProgress = false;
     }
     catch(const OutOfMemoryException&)
     {
-        throw;
-    }
-    catch(...)
-    {
-        fParseInProgress = false;
+        resetInProgress.release();
+
         throw;
     }
 
@@ -1489,20 +1491,18 @@
     if (fParseInProgress)
         ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager);
 
+    ResetInProgressType     resetInProgress(this, &SAX2XMLReaderImpl::resetInProgress);
+
     Grammar* grammar = 0;
     try
     {
         fParseInProgress = true;
         grammar = fScanner->loadGrammar(systemId, grammarType, toCache);
-        fParseInProgress = false;
     }
     catch(const OutOfMemoryException&)
     {
-        throw;
-    }
-    catch(...)
-    {
-        fParseInProgress = false;
+        resetInProgress.release();
+
         throw;
     }
 
@@ -1517,24 +1517,27 @@
     if (fParseInProgress)
         ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager);
 
+    ResetInProgressType     resetInProgress(this, &SAX2XMLReaderImpl::resetInProgress);
+
     Grammar* grammar = 0;
     try
     {
         fParseInProgress = true;
         grammar = fScanner->loadGrammar(source, grammarType, toCache);
-        fParseInProgress = false;
     }
     catch(const OutOfMemoryException&)
     {
-        throw;
-    }
-    catch(...)
-    {
-        fParseInProgress = false;
+        resetInProgress.release();
+
         throw;
     }
 
     return grammar;
+}
+
+void SAX2XMLReaderImpl::resetInProgress()
+{
+    fParseInProgress = false;
 }
 
 void SAX2XMLReaderImpl::resetCachedGrammarPool()

Modified: xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAX2XMLReaderImpl.hpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAX2XMLReaderImpl.hpp?rev=191671&r1=191670&r2=191671&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAX2XMLReaderImpl.hpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAX2XMLReaderImpl.hpp Tue Jun 21 08:48:06 2005
@@ -1581,6 +1581,7 @@
     // -----------------------------------------------------------------------
     void initialize();
     void cleanUp();
+    void resetInProgress();
 
     // -----------------------------------------------------------------------
     //  Private data members

Modified: xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAXParser.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAXParser.cpp?rev=191671&r1=191670&r2=191671&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAXParser.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAXParser.cpp Tue Jun 21 08:48:06 2005
@@ -45,6 +45,12 @@
 // ---------------------------------------------------------------------------
 //  SAXParser: Constructors and Destructor
 // ---------------------------------------------------------------------------
+
+
+typedef JanitorMemFunCall<SAXParser>    CleanupType;
+typedef JanitorMemFunCall<SAXParser>    ResetInProgressType;
+
+
 SAXParser::SAXParser( XMLValidator* const   valToAdopt
                     , MemoryManager* const  manager
                     , XMLGrammarPool* const gramPool):
@@ -68,19 +74,22 @@
     , fGrammarPool(gramPool)
     , fElemQNameBuf(1023, manager)
 {
+    CleanupType cleanup(this, &SAXParser::cleanUp);
+
     try
     {
         initialize();
     }
     catch(const OutOfMemoryException&)
     {
+        // Don't cleanup when out of memory, since executing the
+        // code can cause problems.
+        cleanup.release();
+
         throw;
     }
-    catch(...)
-    {
-        cleanUp();
-        throw;
-    }
+
+    cleanup.release();
 }
 
 
@@ -527,19 +536,17 @@
     if (fParseInProgress)
         ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager);
 
+    ResetInProgressType     resetInProgress(this, &SAXParser::resetInProgress);
+
     try
     {
         fParseInProgress = true;
         fScanner->scanDocument(source);
-        fParseInProgress = false;
     }
     catch(const OutOfMemoryException&)
     {
-        throw;
-    }
-    catch (...)
-    {
-        fParseInProgress = false;
+        resetInProgress.release();
+
         throw;
     }
 }
@@ -550,19 +557,17 @@
     if (fParseInProgress)
         ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager);
 
+    ResetInProgressType     resetInProgress(this, &SAXParser::resetInProgress);
+
     try
     {
         fParseInProgress = true;
         fScanner->scanDocument(systemId);
-        fParseInProgress = false;
     }
     catch(const OutOfMemoryException&)
     {
-        throw;
-    }
-    catch (...)
-    {
-        fParseInProgress = false;
+        resetInProgress.release();
+
         throw;
     }
 }
@@ -573,19 +578,17 @@
     if (fParseInProgress)
         ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager);
 
+    ResetInProgressType     resetInProgress(this, &SAXParser::resetInProgress);
+
     try
     {
         fParseInProgress = true;
         fScanner->scanDocument(systemId);
-        fParseInProgress = false;
     }
     catch(const OutOfMemoryException&)
     {
-        throw;
-    }
-    catch (...)
-    {
-        fParseInProgress = false;
+        resetInProgress.release();
+
         throw;
     }
 }
@@ -1274,20 +1277,18 @@
     if (fParseInProgress)
         ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager);
 
+    ResetInProgressType     resetInProgress(this, &SAXParser::resetInProgress);
+
     Grammar* grammar = 0;
     try
     {
         fParseInProgress = true;
         grammar = fScanner->loadGrammar(systemId, grammarType, toCache);
-        fParseInProgress = false;
     }
     catch(const OutOfMemoryException&)
     {
-        throw;
-    }
-    catch(...)
-    {
-        fParseInProgress = false;
+        resetInProgress.release();
+
         throw;
     }
 
@@ -1302,20 +1303,18 @@
     if (fParseInProgress)
         ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager);
 
+    ResetInProgressType     resetInProgress(this, &SAXParser::resetInProgress);
+
     Grammar* grammar = 0;
     try
     {
         fParseInProgress = true;
         grammar = fScanner->loadGrammar(systemId, grammarType, toCache);
-        fParseInProgress = false;
     }
     catch(const OutOfMemoryException&)
     {
-        throw;
-    }
-    catch(...)
-    {
-        fParseInProgress = false;
+        resetInProgress.release();
+
         throw;
     }
 
@@ -1330,24 +1329,27 @@
     if (fParseInProgress)
         ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager);
 
+    ResetInProgressType     resetInProgress(this, &SAXParser::resetInProgress);
+
     Grammar* grammar = 0;
     try
     {
         fParseInProgress = true;
         grammar = fScanner->loadGrammar(source, grammarType, toCache);
-        fParseInProgress = false;
     }
     catch(const OutOfMemoryException&)
     {
-        throw;
-    }
-    catch(...)
-    {
-        fParseInProgress = false;
+        resetInProgress.release();
+
         throw;
     }
 
     return grammar;
+}
+
+void SAXParser::resetInProgress()
+{
+    fParseInProgress = false;
 }
 
 void SAXParser::resetCachedGrammarPool()

Modified: xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAXParser.hpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAXParser.hpp?rev=191671&r1=191670&r2=191671&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAXParser.hpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/parsers/SAXParser.hpp Tue Jun 21 08:48:06 2005
@@ -2034,6 +2034,7 @@
     // -----------------------------------------------------------------------
     void initialize();
     void cleanUp();
+    void resetInProgress();
 
     // -----------------------------------------------------------------------
     //  Private data members



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org