dbertoni 01/02/12 09:07:57
Modified: c/src/XSLT StylesheetHandler.cpp StylesheetHandler.hpp
Log:
Make sure that pushed locators are popped when handling exceptions.
Revision Changes Path
1.58 +35 -17 xml-xalan/c/src/XSLT/StylesheetHandler.cpp
Index: StylesheetHandler.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetHandler.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- StylesheetHandler.cpp 2001/02/12 02:34:54 1.57
+++ StylesheetHandler.cpp 2001/02/12 17:07:56 1.58
@@ -155,7 +155,8 @@
m_LXSLTScriptBody(),
m_LXSLTScriptLang(),
m_LXSLTScriptSrcURL(),
- m_pLXSLTExtensionNSH(0)
+ m_pLXSLTExtensionNSH(0),
+ m_locatorsPushed(0)
{
}
@@ -210,6 +211,8 @@
void StylesheetHandler::setDocumentLocator(const Locator* const
locator)
{
m_constructionContext.pushLocatorOnStack(locator);
+
+ ++m_locatorsPushed;
}
@@ -225,6 +228,11 @@
{
m_constructionContext.popLocatorStack();
+ if (m_locatorsPushed > 0)
+ {
+ --m_locatorsPushed;
+ }
+
m_inExtensionElementStack.clear();
if (m_exceptionPending == true)
@@ -1159,38 +1167,27 @@
// exceptions need to reach the end user. But the parser eats all
exceptions and we lose
// the error messages and exit silently. So, I'll eat the exceptions
first, store the message
// and then throw the exception during endDocument
- catch(SAXException& e)
+ catch(SAXException& e)
{
m_exceptionPending = true;
- // Pop anything that's not an empty element...
- while(m_elemStack.empty() == false &&
- m_elemStack.back()->getXSLToken() !=
Constants::ELEMNAME_UNDEFINED)
- {
- m_elemStackParentedElements.erase(m_elemStack.back());
- m_elemStack.pop_back();
- }
-
m_pendingException = e.getMessage();
+
+ doCleanup();
}
catch(...)
{
// $$$ ToDo: This probably should't happen, but it does...
m_exceptionPending = true;
- // Pop anything that's not an empty element...
- while(m_elemStack.empty() == false &&
- m_elemStack.back()->getXSLToken() !=
Constants::ELEMNAME_UNDEFINED)
- {
- m_elemStackParentedElements.erase(m_elemStack.back());
- m_elemStack.pop_back();
- }
+ doCleanup();
throw;
}
}
+
ElemTemplateElement*
StylesheetHandler::initWrapperless(
const XalanDOMChar* name,
@@ -1242,6 +1239,27 @@
}
return pElem;
+}
+
+
+
+void
+StylesheetHandler::doCleanup()
+{
+ if (m_locatorsPushed > 0)
+ {
+ m_constructionContext.popLocatorStack();
+
+ --m_locatorsPushed;
+ }
+
+ // Pop anything that's not an empty element...
+ while(m_elemStack.empty() == false &&
+ m_elemStack.back()->getXSLToken() !=
Constants::ELEMNAME_UNDEFINED)
+ {
+ m_elemStackParentedElements.erase(m_elemStack.back());
+ m_elemStack.pop_back();
+ }
}
1.25 +7 -0 xml-xalan/c/src/XSLT/StylesheetHandler.hpp
Index: StylesheetHandler.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetHandler.hpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- StylesheetHandler.hpp 2001/02/08 21:48:01 1.24
+++ StylesheetHandler.hpp 2001/02/12 17:07:57 1.25
@@ -421,6 +421,9 @@
int
theLineNumber,
int
theColumnNumber) const;
+ void
+ doCleanup();
+
private:
// not implemented
@@ -523,6 +526,10 @@
BoolStackType m_inExtensionElementStack;
BoolStackType m_preserveSpaceStack;
+
+ // Note that this variable must not be saved by
+ // PushPopIncludeState...
+ unsigned long m_locatorsPushed;
// BEGIN SANJIVA CODE
bool m_inLXSLTScript;