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 21:01:57 UTC
svn commit: r191707 - in /xerces/c/branches/xerces-2.7/src/xercesc/internal:
DGXMLScanner.cpp IGXMLScanner.cpp ReaderMgr.cpp SGXMLScanner.cpp
WFXMLScanner.cpp
Author: cargilld
Date: Tue Jun 21 12:01:55 2005
New Revision: 191707
URL: http://svn.apache.org/viewcvs?rev=191707&view=rev
Log:
Add back changes Bertoni made that were overwritten.
Modified:
xerces/c/branches/xerces-2.7/src/xercesc/internal/DGXMLScanner.cpp
xerces/c/branches/xerces-2.7/src/xercesc/internal/IGXMLScanner.cpp
xerces/c/branches/xerces-2.7/src/xercesc/internal/ReaderMgr.cpp
xerces/c/branches/xerces-2.7/src/xercesc/internal/SGXMLScanner.cpp
xerces/c/branches/xerces-2.7/src/xercesc/internal/WFXMLScanner.cpp
Modified: xerces/c/branches/xerces-2.7/src/xercesc/internal/DGXMLScanner.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/internal/DGXMLScanner.cpp?rev=191707&r1=191706&r2=191707&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/internal/DGXMLScanner.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/internal/DGXMLScanner.cpp Tue Jun 21 12:01:55 2005
@@ -45,6 +45,11 @@
XERCES_CPP_NAMESPACE_BEGIN
+
+typedef JanitorMemFunCall<DGXMLScanner> CleanupType;
+typedef JanitorMemFunCall<ReaderMgr> ReaderMgrResetType;
+
+
// ---------------------------------------------------------------------------
// DGXMLScanner: Constructors and Destructor
// ---------------------------------------------------------------------------
@@ -61,29 +66,22 @@
, fAttDefRegistry(0)
, fUndeclaredAttrRegistry(0)
{
+ CleanupType cleanup(this, &DGXMLScanner::cleanUp);
+
try
{
commonInit();
-
- if (valToAdopt)
- {
- if (!valToAdopt->handlesDTD())
- ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoDTDValidator, fMemoryManager);
- }
- else
- {
- fValidator = fDTDValidator;
- }
}
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();
}
DGXMLScanner::DGXMLScanner( XMLDocumentHandler* const docHandler
@@ -103,29 +101,22 @@
, fAttDefRegistry(0)
, fUndeclaredAttrRegistry(0)
{
+ CleanupType cleanup(this, &DGXMLScanner::cleanUp);
+
try
{
commonInit();
-
- if (valToAdopt)
- {
- if (!valToAdopt->handlesDTD())
- ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoDTDValidator, fMemoryManager);
- }
- else
- {
- fValidator = fDTDValidator;
- }
}
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();
}
DGXMLScanner::~DGXMLScanner()
@@ -159,6 +150,8 @@
// any previous progressive scan tokens.
fSequenceId++;
+ ReaderMgrResetType resetReaderMgr(&fReaderMgr, &ReaderMgr::reset);
+
try
{
// Reset the scanner and its plugged in stuff for a new run. This
@@ -205,9 +198,6 @@
// If we have a document handler, then call the end document
if (fDocHandler)
fDocHandler->endDocument();
-
- // Reset the reader manager to close all files, sockets, etc...
- fReaderMgr.reset();
}
// NOTE:
//
@@ -216,13 +206,11 @@
// to find out the position in the XML source of the error.
catch(const XMLErrs::Codes)
{
- // This is a 'first fatal error' type exit, so reset and fall through
- fReaderMgr.reset();
+ // This is a 'first failure' exception, so fall through
}
catch(const XMLValid::Codes)
{
- // This is a 'first fatal error' type exit, so reset and fall through
- fReaderMgr.reset();
+ // This is a 'first fatal error' type exit, so fall through
}
catch(const XMLException& excToCatch)
{
@@ -255,26 +243,21 @@
}
catch(const OutOfMemoryException&)
{
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
- catch(...)
- {
- // Flush the reader manager and rethrow user's error
- fReaderMgr.reset();
- throw;
- }
-
- // If it returned, then reset the reader manager and fall through
- fReaderMgr.reset();
}
catch(const OutOfMemoryException&)
{
- throw;
- }
- catch(...)
- {
- // Reset and rethrow
- fReaderMgr.reset();
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
}
@@ -290,6 +273,8 @@
unsigned int orgReader;
XMLTokens curToken;
+ ReaderMgrResetType resetReaderMgr(&fReaderMgr, &ReaderMgr::reset);
+
bool retVal = true;
try
@@ -396,15 +381,13 @@
// to find out the position in the XML source of the error.
catch(const XMLErrs::Codes)
{
- // This is a 'first failure' exception, so reset and return failure
- fReaderMgr.reset();
- return false;
+ // This is a 'first failure' exception, so return failure
+ retVal = false;
}
catch(const XMLValid::Codes)
{
- // This is a 'first fatal error' type exit, so reset and reuturn failure
- fReaderMgr.reset();
- return false;
+ // This is a 'first fatal error' type exit, so return failure
+ retVal = false;
}
catch(const XMLException& excToCatch)
{
@@ -437,33 +420,30 @@
}
catch(const OutOfMemoryException&)
{
- throw;
- }
- catch(...)
- {
- // Reset and rethrow user error
- fReaderMgr.reset();
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
- // Reset and return failure
- fReaderMgr.reset();
- return false;
+ retVal = false;
}
catch(const OutOfMemoryException&)
{
- throw;
- }
- catch(...)
- {
- // Reset and rethrow original error
- fReaderMgr.reset();
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
- // If we hit the end, then flush the reader manager
- if (!retVal)
- fReaderMgr.reset();
+ // If we are not at the end, release the object that will
+ // reset the ReaderMgr.
+ if (retVal)
+ resetReaderMgr.release();
return retVal;
}
@@ -1678,6 +1658,8 @@
{
Grammar* loadedGrammar = 0;
+ ReaderMgrResetType resetReaderMgr(&fReaderMgr, &ReaderMgr::reset);
+
try
{
fGrammarResolver->cacheGrammarFromParse(false);
@@ -1697,9 +1679,6 @@
if (grammarType == Grammar::DTDGrammarType) {
loadedGrammar = loadDTDGrammar(src, toCache);
}
-
- // Reset the reader manager to close all files, sockets, etc...
- fReaderMgr.reset();
}
// NOTE:
//
@@ -1708,14 +1687,11 @@
// to find out the position in the XML source of the error.
catch(const XMLErrs::Codes)
{
- // This is a 'first fatal error' type exit, so reset and fall through
- fReaderMgr.reset();
+ // This is a 'first failure' exception, so fall through
}
catch(const XMLValid::Codes)
{
- // This is a 'first fatal error' type exit, so reset and fall through
- fReaderMgr.reset();
-
+ // This is a 'first fatal error' type exit, so fall through
}
catch(const XMLException& excToCatch)
{
@@ -1747,26 +1723,21 @@
}
catch(const OutOfMemoryException&)
{
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
- catch(...)
- {
- // Flush the reader manager and rethrow user's error
- fReaderMgr.reset();
- throw;
- }
-
- // If it returned, then reset the reader manager and fall through
- fReaderMgr.reset();
}
catch(const OutOfMemoryException&)
{
- throw;
- }
- catch(...)
- {
- // Reset and rethrow
- fReaderMgr.reset();
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
@@ -1893,7 +1864,6 @@
// it redundantly in multiple constructors.
void DGXMLScanner::commonInit()
{
-
// And we need one for the raw attribute scan. This just stores key/
// value string pairs (prior to any processing.)
fAttrNSList = new (fMemoryManager) ValueVectorOf<XMLAttr*>(8, fMemoryManager);
@@ -1910,6 +1880,16 @@
(
7, false, new (fMemoryManager)HashXMLCh(), fMemoryManager
);
+
+ if (fValidator)
+ {
+ if (!fValidator->handlesDTD())
+ ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoDTDValidator, fMemoryManager);
+ }
+ else
+ {
+ fValidator = fDTDValidator;
+ }
}
void DGXMLScanner::cleanUp()
Modified: xerces/c/branches/xerces-2.7/src/xercesc/internal/IGXMLScanner.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/internal/IGXMLScanner.cpp?rev=191707&r1=191706&r2=191707&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/internal/IGXMLScanner.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/internal/IGXMLScanner.cpp Tue Jun 21 12:01:55 2005
@@ -47,6 +47,11 @@
XERCES_CPP_NAMESPACE_BEGIN
+
+typedef JanitorMemFunCall<IGXMLScanner> CleanupType;
+typedef JanitorMemFunCall<ReaderMgr> ReaderMgrResetType;
+
+
// ---------------------------------------------------------------------------
// IGXMLScanner: Constructors and Destructor
// ---------------------------------------------------------------------------
@@ -79,23 +84,22 @@
, fPSVIElement(0)
, fErrorStack(0)
{
+ CleanupType cleanup(this, &IGXMLScanner::cleanUp);
+
try
{
- commonInit();
-
- // use fDTDValidator as the default validator
- if (!valToAdopt)
- fValidator = fDTDValidator;
+ commonInit();
}
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();
}
IGXMLScanner::IGXMLScanner( XMLDocumentHandler* const docHandler
@@ -131,23 +135,22 @@
, fPSVIElement(0)
, fErrorStack(0)
{
+ CleanupType cleanup(this, &IGXMLScanner::cleanUp);
+
try
{
commonInit();
-
- //use fDTDValidator as the default validator
- if (!valToAdopt)
- fValidator = fDTDValidator;
}
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();
}
IGXMLScanner::~IGXMLScanner()
@@ -181,6 +184,8 @@
// any previous progressive scan tokens.
fSequenceId++;
+ ReaderMgrResetType resetReaderMgr(&fReaderMgr, &ReaderMgr::reset);
+
try
{
// Reset the scanner and its plugged in stuff for a new run. This
@@ -230,9 +235,6 @@
//cargill debug:
//fGrammarResolver->getXSModel();
-
- // Reset the reader manager to close all files, sockets, etc...
- fReaderMgr.reset();
}
// NOTE:
//
@@ -241,13 +243,11 @@
// to find out the position in the XML source of the error.
catch(const XMLErrs::Codes)
{
- // This is a 'first fatal error' type exit, so reset and fall through
- fReaderMgr.reset();
+ // This is a 'first failure' exception, so fall through
}
catch(const XMLValid::Codes)
{
- // This is a 'first fatal error' type exit, so reset and fall through
- fReaderMgr.reset();
+ // This is a 'first fatal error' type exit, so fall through
}
catch(const XMLException& excToCatch)
{
@@ -280,26 +280,21 @@
}
catch(const OutOfMemoryException&)
{
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
- catch(...)
- {
- // Flush the reader manager and rethrow user's error
- fReaderMgr.reset();
- throw;
- }
-
- // If it returned, then reset the reader manager and fall through
- fReaderMgr.reset();
}
catch(const OutOfMemoryException&)
{
- throw;
- }
- catch(...)
- {
- // Reset and rethrow
- fReaderMgr.reset();
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
}
@@ -315,6 +310,8 @@
unsigned int orgReader;
XMLTokens curToken;
+ ReaderMgrResetType resetReaderMgr(&fReaderMgr, &ReaderMgr::reset);
+
bool retVal = true;
try
@@ -427,15 +424,13 @@
// to find out the position in the XML source of the error.
catch(const XMLErrs::Codes)
{
- // This is a 'first failure' exception, so reset and return failure
- fReaderMgr.reset();
- return false;
+ // This is a 'first failure' exception so return failure
+ retVal = false;
}
catch(const XMLValid::Codes)
{
- // This is a 'first fatal error' type exit, so reset and reuturn failure
- fReaderMgr.reset();
- return false;
+ // This is a 'first fatal error' type exit, so return failure
+ retVal = false;
}
catch(const XMLException& excToCatch)
{
@@ -468,33 +463,30 @@
}
catch(const OutOfMemoryException&)
{
- throw;
- }
- catch(...)
- {
- // Reset and rethrow user error
- fReaderMgr.reset();
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
- // Reset and return failure
- fReaderMgr.reset();
- return false;
+ retVal = false;
}
catch(const OutOfMemoryException&)
{
- throw;
- }
- catch(...)
- {
- // Reset and rethrow original error
- fReaderMgr.reset();
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
- // If we hit the end, then flush the reader manager
- if (!retVal)
- fReaderMgr.reset();
+ // If we are not at the end, release the object that will
+ // reset the ReaderMgr.
+ if (retVal)
+ resetReaderMgr.release();
return retVal;
}
@@ -552,6 +544,10 @@
7, false, new (fMemoryManager)HashXMLCh(), fMemoryManager
);
fPSVIAttrList = new (fMemoryManager) PSVIAttributeList(fMemoryManager);
+
+ // use fDTDValidator as the default validator
+ if (!fValidator)
+ fValidator = fDTDValidator;
}
void IGXMLScanner::cleanUp()
@@ -2945,6 +2941,8 @@
{
Grammar* loadedGrammar = 0;
+ ReaderMgrResetType resetReaderMgr(&fReaderMgr, &ReaderMgr::reset);
+
try
{
fGrammarResolver->cacheGrammarFromParse(false);
@@ -2971,9 +2969,6 @@
else if (grammarType == Grammar::DTDGrammarType) {
loadedGrammar = loadDTDGrammar(src, toCache);
}
-
- // Reset the reader manager to close all files, sockets, etc...
- fReaderMgr.reset();
}
// NOTE:
//
@@ -2982,14 +2977,11 @@
// to find out the position in the XML source of the error.
catch(const XMLErrs::Codes)
{
- // This is a 'first fatal error' type exit, so reset and fall through
- fReaderMgr.reset();
+ // This is a 'first fatal error' type exit, so fall through
}
catch(const XMLValid::Codes)
{
- // This is a 'first fatal error' type exit, so reset and fall through
- fReaderMgr.reset();
-
+ // This is a 'first fatal error' type exit, so fall through
}
catch(const XMLException& excToCatch)
{
@@ -3021,26 +3013,21 @@
}
catch(const OutOfMemoryException&)
{
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
- catch(...)
- {
- // Flush the reader manager and rethrow user's error
- fReaderMgr.reset();
- throw;
- }
-
- // If it returned, then reset the reader manager and fall through
- fReaderMgr.reset();
}
catch(const OutOfMemoryException&)
{
- throw;
- }
- catch(...)
- {
- // Reset and rethrow
- fReaderMgr.reset();
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
Modified: xerces/c/branches/xerces-2.7/src/xercesc/internal/ReaderMgr.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/internal/ReaderMgr.cpp?rev=191707&r1=191706&r2=191707&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/internal/ReaderMgr.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/internal/ReaderMgr.cpp Tue Jun 21 12:01:55 2005
@@ -387,6 +387,8 @@
if (!newStream)
return 0;
+ Janitor<BinInputStream> streamJanitor(newStream);
+
//
// Create a new reader and return it. If the source has an encoding that
// it wants to force, then we call the constructor that does that.
@@ -438,19 +440,14 @@
}
catch(const OutOfMemoryException&)
{
- throw;
- }
- catch (...) //NetAccessorException&
- {
- delete newStream;
+ streamJanitor.release();
+
throw;
}
- // If it failed for any reason, then return zero.
- if (!retVal) {
- delete newStream;
- return 0;
- }
+ assert(retVal);
+
+ streamJanitor.release();
// Set the next available reader number on this reader
retVal->setReaderNum(fNextReaderNum++);
Modified: xerces/c/branches/xerces-2.7/src/xercesc/internal/SGXMLScanner.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/internal/SGXMLScanner.cpp?rev=191707&r1=191706&r2=191707&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/internal/SGXMLScanner.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/internal/SGXMLScanner.cpp Tue Jun 21 12:01:55 2005
@@ -51,6 +51,11 @@
inline XMLAttDefList& getAttDefList(ComplexTypeInfo* currType, XMLElementDecl* elemDecl);
+
+typedef JanitorMemFunCall<SGXMLScanner> CleanupType;
+typedef JanitorMemFunCall<ReaderMgr> ReaderMgrResetType;
+
+
// ---------------------------------------------------------------------------
// SGXMLScanner: Constructors and Destructor
// ---------------------------------------------------------------------------
@@ -80,29 +85,22 @@
, fPSVIElement(0)
, fErrorStack(0)
{
+ CleanupType cleanup(this, &SGXMLScanner::cleanUp);
+
try
{
commonInit();
-
- if (valToAdopt)
- {
- if (!valToAdopt->handlesSchema())
- ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoSchemaValidator, fMemoryManager);
- }
- else
- {
- fValidator = fSchemaValidator;
- }
}
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();
}
SGXMLScanner::SGXMLScanner( XMLDocumentHandler* const docHandler
@@ -135,29 +133,22 @@
, fPSVIElement(0)
, fErrorStack(0)
{
+ CleanupType cleanup(this, &SGXMLScanner::cleanUp);
+
try
{
commonInit();
-
- if (valToAdopt)
- {
- if (!valToAdopt->handlesSchema())
- ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoSchemaValidator, fMemoryManager);
- }
- else
- {
- fValidator = fSchemaValidator;
- }
}
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();
}
SGXMLScanner::~SGXMLScanner()
@@ -187,6 +178,8 @@
// any previous progressive scan tokens.
fSequenceId++;
+ ReaderMgrResetType resetReaderMgr(&fReaderMgr, &ReaderMgr::reset);
+
try
{
// Reset the scanner and its plugged in stuff for a new run. This
@@ -233,9 +226,6 @@
// If we have a document handler, then call the end document
if (fDocHandler)
fDocHandler->endDocument();
-
- // Reset the reader manager to close all files, sockets, etc...
- fReaderMgr.reset();
}
// NOTE:
//
@@ -244,13 +234,11 @@
// to find out the position in the XML source of the error.
catch(const XMLErrs::Codes)
{
- // This is a 'first fatal error' type exit, so reset and fall through
- fReaderMgr.reset();
+ // This is a 'first failure' exception, so fall through
}
catch(const XMLValid::Codes)
{
- // This is a 'first fatal error' type exit, so reset and fall through
- fReaderMgr.reset();
+ // This is a 'first fatal error' type exit, so fall through
}
catch(const XMLException& excToCatch)
{
@@ -283,26 +271,21 @@
}
catch(const OutOfMemoryException&)
{
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
- catch(...)
- {
- // Flush the reader manager and rethrow user's error
- fReaderMgr.reset();
- throw;
- }
-
- // If it returned, then reset the reader manager and fall through
- fReaderMgr.reset();
}
catch(const OutOfMemoryException&)
{
- throw;
- }
- catch(...)
- {
- // Reset and rethrow
- fReaderMgr.reset();
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
}
@@ -318,6 +301,8 @@
unsigned int orgReader;
XMLTokens curToken;
+ ReaderMgrResetType resetReaderMgr(&fReaderMgr, &ReaderMgr::reset);
+
bool retVal = true;
try
@@ -427,15 +412,13 @@
// to find out the position in the XML source of the error.
catch(const XMLErrs::Codes)
{
- // This is a 'first failure' exception, so reset and return failure
- fReaderMgr.reset();
- return false;
+ // This is a 'first failure' exception, so return failure
+ retVal = false;
}
catch(const XMLValid::Codes)
{
- // This is a 'first fatal error' type exit, so reset and reuturn failure
- fReaderMgr.reset();
- return false;
+ // This is a 'first fatal error' type exit, so return failure
+ retVal = false;
}
catch(const XMLException& excToCatch)
{
@@ -468,33 +451,30 @@
}
catch(const OutOfMemoryException&)
{
- throw;
- }
- catch(...)
- {
- // Reset and rethrow user error
- fReaderMgr.reset();
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
- // Reset and return failure
- fReaderMgr.reset();
- return false;
+ retVal = false;
}
catch(const OutOfMemoryException&)
{
- throw;
- }
- catch(...)
- {
- // Reset and rethrow original error
- fReaderMgr.reset();
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
- // If we hit the end, then flush the reader manager
- if (!retVal)
- fReaderMgr.reset();
+ // If we are not at the end, release the object that will
+ // reset the ReaderMgr.
+ if (retVal)
+ resetReaderMgr.release();
return retVal;
}
@@ -1890,6 +1870,8 @@
{
Grammar* loadedGrammar = 0;
+ ReaderMgrResetType resetReaderMgr(&fReaderMgr, &ReaderMgr::reset);
+
try
{
fGrammarResolver->cacheGrammarFromParse(false);
@@ -1913,9 +1895,6 @@
if (grammarType == Grammar::SchemaGrammarType) {
loadedGrammar = loadXMLSchemaGrammar(src, toCache);
}
-
- // Reset the reader manager to close all files, sockets, etc...
- fReaderMgr.reset();
}
// NOTE:
//
@@ -1924,14 +1903,11 @@
// to find out the position in the XML source of the error.
catch(const XMLErrs::Codes)
{
- // This is a 'first fatal error' type exit, so reset and fall through
- fReaderMgr.reset();
+ // This is a 'first failure' exception, so fall through
}
catch(const XMLValid::Codes)
{
- // This is a 'first fatal error' type exit, so reset and fall through
- fReaderMgr.reset();
-
+ // This is a 'first fatal error' type exit, so fall through
}
catch(const XMLException& excToCatch)
{
@@ -1963,26 +1939,21 @@
}
catch(const OutOfMemoryException&)
{
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
- catch(...)
- {
- // Flush the reader manager and rethrow user's error
- fReaderMgr.reset();
- throw;
- }
-
- // If it returned, then reset the reader manager and fall through
- fReaderMgr.reset();
}
catch(const OutOfMemoryException&)
{
- throw;
- }
- catch(...)
- {
- // Reset and rethrow
- fReaderMgr.reset();
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
@@ -2035,6 +2006,16 @@
7, false, new (fMemoryManager)HashXMLCh(), fMemoryManager
);
fPSVIAttrList = new (fMemoryManager) PSVIAttributeList(fMemoryManager);
+
+ if (fValidator)
+ {
+ if (!fValidator->handlesSchema())
+ ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoSchemaValidator, fMemoryManager);
+ }
+ else
+ {
+ fValidator = fSchemaValidator;
+ }
}
void SGXMLScanner::cleanUp()
Modified: xerces/c/branches/xerces-2.7/src/xercesc/internal/WFXMLScanner.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/internal/WFXMLScanner.cpp?rev=191707&r1=191706&r2=191707&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/internal/WFXMLScanner.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/internal/WFXMLScanner.cpp Tue Jun 21 12:01:55 2005
@@ -39,6 +39,12 @@
// ---------------------------------------------------------------------------
// WFXMLScanner: Constructors and Destructor
// ---------------------------------------------------------------------------
+
+
+typedef JanitorMemFunCall<WFXMLScanner> CleanupType;
+typedef JanitorMemFunCall<ReaderMgr> ReaderMgrResetType;
+
+
WFXMLScanner::WFXMLScanner( XMLValidator* const valToAdopt
, GrammarResolver* const grammarResolver
, MemoryManager* const manager) :
@@ -51,19 +57,22 @@
, fAttrNSList(0)
, fElementLookup(0)
{
+ CleanupType cleanup(this, &WFXMLScanner::cleanUp);
+
try
{
commonInit();
}
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();
}
WFXMLScanner::WFXMLScanner( XMLDocumentHandler* const docHandler
@@ -82,19 +91,22 @@
, fAttrNSList(0)
, fElementLookup(0)
{
+ CleanupType cleanup(this, &WFXMLScanner::cleanUp);
+
try
{
commonInit();
}
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();
}
WFXMLScanner::~WFXMLScanner()
@@ -124,6 +136,8 @@
// any previous progressive scan tokens.
fSequenceId++;
+ ReaderMgrResetType resetReaderMgr(&fReaderMgr, &ReaderMgr::reset);
+
try
{
// Reset the scanner and its plugged in stuff for a new run. This
@@ -159,9 +173,6 @@
// If we have a document handler, then call the end document
if (fDocHandler)
fDocHandler->endDocument();
-
- // Reset the reader manager to close all files, sockets, etc...
- fReaderMgr.reset();
}
// NOTE:
//
@@ -170,13 +181,11 @@
// to find out the position in the XML source of the error.
catch(const XMLErrs::Codes)
{
- // This is a 'first fatal error' type exit, so reset and fall through
- fReaderMgr.reset();
+ // This is a 'first failure' exception, so fall through
}
catch(const XMLValid::Codes)
{
- // This is a 'first fatal error' type exit, so reset and fall through
- fReaderMgr.reset();
+ // This is a 'first fatal error' type exit, so fall through
}
catch(const XMLException& excToCatch)
{
@@ -209,26 +218,21 @@
}
catch(const OutOfMemoryException&)
{
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
- catch(...)
- {
- // Flush the reader manager and rethrow user's error
- fReaderMgr.reset();
- throw;
- }
-
- // If it returned, then reset the reader manager and fall through
- fReaderMgr.reset();
}
catch(const OutOfMemoryException&)
{
- throw;
- }
- catch(...)
- {
- // Reset and rethrow
- fReaderMgr.reset();
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
}
@@ -245,6 +249,8 @@
XMLTokens curToken;
bool retVal = true;
+ ReaderMgrResetType resetReaderMgr(&fReaderMgr, &ReaderMgr::reset);
+
try
{
while (true)
@@ -341,15 +347,13 @@
// to find out the position in the XML source of the error.
catch(const XMLErrs::Codes)
{
- // This is a 'first failure' exception, so reset and return failure
- fReaderMgr.reset();
- return false;
+ // This is a 'first failure' exception, so return failure
+ retVal = false;
}
catch(const XMLValid::Codes)
{
- // This is a 'first fatal error' type exit, so reset and reuturn failure
- fReaderMgr.reset();
- return false;
+ // This is a 'first fatal error' type exit, so return failure
+ retVal = false;
}
catch(const XMLException& excToCatch)
{
@@ -382,33 +386,26 @@
}
catch(const OutOfMemoryException&)
{
- throw;
- }
- catch(...)
- {
- // Reset and rethrow user error
- fReaderMgr.reset();
+ // This is a special case for out-of-memory
+ // conditions, because resetting the ReaderMgr
+ // can be problematic.
+ resetReaderMgr.release();
+
throw;
}
- // Reset and return failure
- fReaderMgr.reset();
- return false;
+ // Return failure
+ retVal = false;
}
catch(const OutOfMemoryException&)
{
throw;
}
- catch(...)
- {
- // Reset and rethrow original error
- fReaderMgr.reset();
- throw;
- }
- // If we hit the end, then flush the reader manager
- if (!retVal)
- fReaderMgr.reset();
+ // If we are not at the end, release the object that will
+ // reset the ReaderMgr.
+ if (retVal)
+ resetReaderMgr.release();
return retVal;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org