summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2011-12-07 16:11:57 +0100
committerEike Rathke <erack@redhat.com>2011-12-07 17:27:31 +0100
commitcabf25372cf98869616c3d583eb99fa5f5eb3a8f (patch)
tree477ad848a6c40141f00c84e6bbfc0375c4517cfd /starmath
parentd432b00bfa05b1bd1413fb0b9afac19de5c1f60b (diff)
old class Stack pop'ed 0 from empty stack, which std::stack doesn't
Some places in the code assumed that if the stack is empty a null pointer is returned by top() (or old Pop()), this doesn't work anymore with ::std::stack that instead has undefined behavior in that case, so check !stack.empty() first before accessing top. (cherry picked from commit ac40f7d6503533954127e818f2bf009200c1e3f2)
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/mathmlimport.cxx94
-rw-r--r--starmath/source/mathmlimport.hxx2
-rw-r--r--starmath/source/parse.cxx124
3 files changed, 92 insertions, 128 deletions
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index 0db8cc499d6f..92901276eb8c 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -95,6 +95,18 @@ using ::rtl::OUStringBuffer;
////////////////////////////////////////////////////////////
+namespace {
+template < typename T >
+T* lcl_popOrZero( ::std::stack<T*> & rStack )
+{
+ if (rStack.empty())
+ return 0;
+ T* pTmp = rStack.top();
+ rStack.pop();
+ return pTmp;
+}
+}
+
sal_uLong SmXMLImportWrapper::Import(SfxMedium &rMedium)
{
sal_uLong nError = ERRCODE_SFX_DOLOADFAILED;
@@ -747,8 +759,7 @@ void SmXMLContext_Helper::ApplyAttrs()
aToken.eType = TNBOLD;
SmStructureNode *pFontNode = static_cast<SmStructureNode *>
(new SmFontNode(aToken));
- pFontNode->SetSubNodes(0,rNodeStack.top());
- rNodeStack.pop();
+ pFontNode->SetSubNodes(0,lcl_popOrZero(rNodeStack));
rNodeStack.push(pFontNode);
}
if (nIsItalic != -1)
@@ -759,8 +770,7 @@ void SmXMLContext_Helper::ApplyAttrs()
aToken.eType = TNITALIC;
SmStructureNode *pFontNode = static_cast<SmStructureNode *>
(new SmFontNode(aToken));
- pFontNode->SetSubNodes(0,rNodeStack.top());
- rNodeStack.pop();
+ pFontNode->SetSubNodes(0,lcl_popOrZero(rNodeStack));
rNodeStack.push(pFontNode);
}
if (nFontSize != 0.0)
@@ -781,8 +791,7 @@ void SmXMLContext_Helper::ApplyAttrs()
else
pFontNode->SetSizeParameter(Fraction(nFontSize),FNTSIZ_ABSOLUT);
- pFontNode->SetSubNodes(0,rNodeStack.top());
- rNodeStack.pop();
+ pFontNode->SetSubNodes(0,lcl_popOrZero(rNodeStack));
rNodeStack.push(pFontNode);
}
if (sFontFamily.getLength())
@@ -801,8 +810,7 @@ void SmXMLContext_Helper::ApplyAttrs()
aToken.aText = sFontFamily;
SmFontNode *pFontNode = new SmFontNode(aToken);
- pFontNode->SetSubNodes(0,rNodeStack.top());
- rNodeStack.pop();
+ pFontNode->SetSubNodes(0,lcl_popOrZero(rNodeStack));
rNodeStack.push(pFontNode);
}
if (sColor.getLength())
@@ -816,8 +824,7 @@ void SmXMLContext_Helper::ApplyAttrs()
if (aToken.eType != -1)
{
SmFontNode *pFontNode = new SmFontNode(aToken);
- pFontNode->SetSubNodes(0,rNodeStack.top());
- rNodeStack.pop();
+ pFontNode->SetSubNodes(0,lcl_popOrZero(rNodeStack));
rNodeStack.push(pFontNode);
}
}
@@ -991,8 +998,7 @@ void SmXMLPhantomContext_Impl::EndElement()
SmStructureNode *pPhantom = static_cast<SmStructureNode *>
(new SmFontNode(aToken));
SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- pPhantom->SetSubNodes(0,rNodeStack.top());
- rNodeStack.pop();
+ pPhantom->SetSubNodes(0,lcl_popOrZero(rNodeStack));
rNodeStack.push(pPhantom);
}
@@ -1482,10 +1488,8 @@ void SmXMLSubContext_Impl::GenericEndElement(SmTokenType eType, SmSubSup eSubSup
for (sal_uLong i = 1; i < aSubNodes.size(); i++)
aSubNodes[i] = NULL;
- aSubNodes[eSubSup+1] = rNodeStack.top();
- rNodeStack.pop();
- aSubNodes[0] = rNodeStack.top();
- rNodeStack.pop();
+ aSubNodes[eSubSup+1] = lcl_popOrZero(rNodeStack);
+ aSubNodes[0] = lcl_popOrZero(rNodeStack);
pNode->SetSubNodes(aSubNodes);
rNodeStack.push(pNode);
}
@@ -1546,12 +1550,9 @@ void SmXMLSubSupContext_Impl::GenericEndElement(SmTokenType eType,
for (sal_uLong i = 1; i < aSubNodes.size(); i++)
aSubNodes[i] = NULL;
- aSubNodes[aSup+1] = rNodeStack.top();
- rNodeStack.pop();
- aSubNodes[aSub+1] = rNodeStack.top();
- rNodeStack.pop();
- aSubNodes[0] = rNodeStack.top();
- rNodeStack.pop();
+ aSubNodes[aSup+1] = lcl_popOrZero(rNodeStack);
+ aSubNodes[aSub+1] = lcl_popOrZero(rNodeStack);
+ aSubNodes[0] = lcl_popOrZero(rNodeStack);
pNode->SetSubNodes(aSubNodes);
rNodeStack.push(pNode);
}
@@ -1588,8 +1589,7 @@ void SmXMLUnderContext_Impl::HandleAccent()
/*Just one special case for the underline thing*/
SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- SmNode *pTest = rNodeStack.top();
- rNodeStack.pop();
+ SmNode *pTest = lcl_popOrZero(rNodeStack);
SmToken aToken;
aToken.cMathChar = '\0';
aToken.nGroup = 0;
@@ -1609,8 +1609,7 @@ void SmXMLUnderContext_Impl::HandleAccent()
else
aSubNodes[0] = pTest;
- aSubNodes[1] = rNodeStack.top();
- rNodeStack.pop();
+ aSubNodes[1] = lcl_popOrZero(rNodeStack);
pNode->SetSubNodes(aSubNodes);
pNode->SetScaleMode(SCALE_WIDTH);
rNodeStack.push(pNode);
@@ -1677,10 +1676,8 @@ void SmXMLOverContext_Impl::HandleAccent()
SmNodeArray aSubNodes;
aSubNodes.resize(2);
- aSubNodes[0] = rNodeStack.top();
- rNodeStack.pop();
- aSubNodes[1] = rNodeStack.top();
- rNodeStack.pop();
+ aSubNodes[0] = lcl_popOrZero(rNodeStack);
+ aSubNodes[1] = lcl_popOrZero(rNodeStack);
pNode->SetSubNodes(aSubNodes);
pNode->SetScaleMode(SCALE_WIDTH);
rNodeStack.push(pNode);
@@ -2194,11 +2191,7 @@ void SmXMLDocContext_Impl::EndElement()
ContextArray.resize(1);
SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- for (sal_uLong i=0;i< 1;i++)
- {
- ContextArray[i] = rNodeStack.top();
- rNodeStack.pop();
- }
+ ContextArray[0] = lcl_popOrZero(rNodeStack);
SmToken aDummy;
SmStructureNode *pSNode = new SmLineNode(aDummy);
@@ -2233,10 +2226,8 @@ void SmXMLFracContext_Impl::EndElement()
aToken.eType = TOVER;
SmStructureNode *pSNode = new SmBinVerNode(aToken);
SmNode *pOper = new SmRectangleNode(aToken);
- SmNode *pSecond = rNodeStack.top();
- rNodeStack.pop();
- SmNode *pFirst = rNodeStack.top();
- rNodeStack.pop();
+ SmNode *pSecond = lcl_popOrZero(rNodeStack);
+ SmNode *pFirst = lcl_popOrZero(rNodeStack);
pSNode->SetSubNodes(pFirst,pOper,pSecond);
rNodeStack.push(pSNode);
}
@@ -2257,10 +2248,8 @@ void SmXMLRootContext_Impl::EndElement()
SmStructureNode *pSNode = new SmRootNode(aToken);
SmNode *pOper = new SmRootSymbolNode(aToken);
SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- SmNode *pIndex = rNodeStack.top();
- rNodeStack.pop();
- SmNode *pBase = rNodeStack.top();
- rNodeStack.pop();
+ SmNode *pIndex = lcl_popOrZero(rNodeStack);
+ SmNode *pBase = lcl_popOrZero(rNodeStack);
pSNode->SetSubNodes(pIndex,pOper,pBase);
rNodeStack.push(pSNode);
}
@@ -2283,8 +2272,7 @@ void SmXMLSqrtContext_Impl::EndElement()
SmStructureNode *pSNode = new SmRootNode(aToken);
SmNode *pOper = new SmRootSymbolNode(aToken);
SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- pSNode->SetSubNodes(0,pOper,rNodeStack.top());
- rNodeStack.pop();
+ pSNode->SetSubNodes(0,pOper,lcl_popOrZero(rNodeStack));
rNodeStack.push(pSNode);
}
@@ -2297,7 +2285,7 @@ void SmXMLRowContext_Impl::EndElement()
if (nSize > 0)
{
aRelationArray.resize(nSize);
- for (sal_uLong j=rNodeStack.size()-nElementCount;j > 0;j--)
+ for (sal_uLong j=nSize;j > 0;j--)
{
aRelationArray[j-1] = rNodeStack.top();
rNodeStack.pop();
@@ -2525,17 +2513,14 @@ void SmXMLMultiScriptsContext_Impl::ProcessSubSupPairs(bool bIsPrescript)
/*On each loop the base and its sub sup pair becomes the
base for the next loop to which the next sub sup pair is
attached, i.e. wheels within wheels*/
- aSubNodes[0] = aReverseStack.top();
- aReverseStack.pop();
+ aSubNodes[0] = lcl_popOrZero(aReverseStack);
- SmNode *pScriptNode = aReverseStack.top();
- aReverseStack.pop();
+ SmNode *pScriptNode = lcl_popOrZero(aReverseStack);
if (pScriptNode && ((pScriptNode->GetToken().eType != TIDENT) ||
(pScriptNode->GetToken().aText.Len())))
aSubNodes[eSub+1] = pScriptNode;
- pScriptNode = aReverseStack.top();
- aReverseStack.pop();
+ pScriptNode = lcl_popOrZero(aReverseStack);
if (pScriptNode && ((pScriptNode->GetToken().eType != TIDENT) ||
(pScriptNode->GetToken().aText.Len())))
aSubNodes[eSup+1] = pScriptNode;
@@ -2543,8 +2528,7 @@ void SmXMLMultiScriptsContext_Impl::ProcessSubSupPairs(bool bIsPrescript)
pNode->SetSubNodes(aSubNodes);
aReverseStack.push(pNode);
}
- rNodeStack.push(aReverseStack.top());
- aReverseStack.pop();
+ rNodeStack.push(lcl_popOrZero(aReverseStack));
}
else
{
@@ -2569,7 +2553,7 @@ void SmXMLTableContext_Impl::EndElement()
sal_uInt16 nCols = 0;
SmStructureNode *pArray;
- for (sal_uLong i=rNodeStack.size()-nElementCount;i > 0;i--)
+ for (sal_uLong i=nRows;i > 0;i--)
{
pArray = (SmStructureNode *)rNodeStack.top();
rNodeStack.pop();
diff --git a/starmath/source/mathmlimport.hxx b/starmath/source/mathmlimport.hxx
index 5ed8096300ac..e67e6a079bbe 100644
--- a/starmath/source/mathmlimport.hxx
+++ b/starmath/source/mathmlimport.hxx
@@ -254,6 +254,8 @@ public:
SmNodeStack & GetNodeStack() { return aNodeStack; }
SmNode *GetTree()
{
+ if (aNodeStack.empty())
+ return 0;
SmNode* result = aNodeStack.top();
aNodeStack.pop();
return result;
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 7a2741f1f365..34425ab6acc7 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -51,6 +51,18 @@ using namespace ::com::sun::star::i18n;
///////////////////////////////////////////////////////////////////////////
+namespace {
+template < typename T >
+T* lcl_popOrZero( ::std::stack<T*> & rStack )
+{
+ if (rStack.empty())
+ return 0;
+ T* pTmp = rStack.top();
+ rStack.pop();
+ return pTmp;
+}
+}
+
static inline bool strnccmp(const String &u1, xub_StrLen nIdx,
const sal_Char *s2, xub_StrLen nLen)
{
@@ -1066,8 +1078,7 @@ void SmParser::Align()
if (pSNode)
{
- pSNode->SetSubNodes(m_aNodeStack.top(), 0);
- m_aNodeStack.pop();
+ pSNode->SetSubNodes(lcl_popOrZero(m_aNodeStack), 0);
m_aNodeStack.push(pSNode);
}
}
@@ -1086,8 +1097,7 @@ void SmParser::Line()
if (m_aCurToken.eType != TEND && m_aCurToken.eType != TNEWLINE)
{ Align();
ExpressionArray.resize(++n);
- ExpressionArray[n - 1] = m_aNodeStack.top();
- m_aNodeStack.pop();
+ ExpressionArray[n - 1] = lcl_popOrZero(m_aNodeStack);
}
while (m_aCurToken.eType != TEND && m_aCurToken.eType != TNEWLINE)
@@ -1096,8 +1106,7 @@ void SmParser::Line()
else
Align();
ExpressionArray.resize(++n);
- ExpressionArray[n - 1] = m_aNodeStack.top();
- m_aNodeStack.pop();
+ ExpressionArray[n - 1] = lcl_popOrZero(m_aNodeStack);
}
//If there's no expression, add an empty one.
@@ -1132,14 +1141,12 @@ void SmParser::Expression()
Relation();
RelationArray.resize(++n);
- RelationArray[n - 1] = m_aNodeStack.top();
- m_aNodeStack.pop();
+ RelationArray[n - 1] = lcl_popOrZero(m_aNodeStack);
while (m_aCurToken.nLevel >= 4)
{ Relation();
RelationArray.resize(++n);
- RelationArray[n - 1] = m_aNodeStack.top();
- m_aNodeStack.pop();
+ RelationArray[n - 1] = lcl_popOrZero(m_aNodeStack);
}
SmExpressionNode *pSNode = new SmExpressionNode(m_aCurToken);
@@ -1155,17 +1162,14 @@ void SmParser::Relation()
while (TokenInGroup(TGRELATION))
{
SmStructureNode *pSNode = new SmBinHorNode(m_aCurToken);
- SmNode *pFirst = m_aNodeStack.top();
- m_aNodeStack.pop();
+ SmNode *pFirst = lcl_popOrZero(m_aNodeStack);
OpSubSup();
- SmNode *pSecond = m_aNodeStack.top();
- m_aNodeStack.pop();
+ SmNode *pSecond = lcl_popOrZero(m_aNodeStack);
Sum();
- pSNode->SetSubNodes(pFirst, pSecond, m_aNodeStack.top());
- m_aNodeStack.pop();
+ pSNode->SetSubNodes(pFirst, pSecond, lcl_popOrZero(m_aNodeStack));
m_aNodeStack.push(pSNode);
}
}
@@ -1177,17 +1181,14 @@ void SmParser::Sum()
while (TokenInGroup(TGSUM))
{
SmStructureNode *pSNode = new SmBinHorNode(m_aCurToken);
- SmNode *pFirst = m_aNodeStack.top();
- m_aNodeStack.pop();
+ SmNode *pFirst = lcl_popOrZero(m_aNodeStack);
OpSubSup();
- SmNode *pSecond = m_aNodeStack.top();
- m_aNodeStack.pop();
+ SmNode *pSecond = lcl_popOrZero(m_aNodeStack);
Product();
- pSNode->SetSubNodes(pFirst, pSecond, m_aNodeStack.top());
- m_aNodeStack.pop();
+ pSNode->SetSubNodes(pFirst, pSecond, lcl_popOrZero(m_aNodeStack));
m_aNodeStack.push(pSNode);
}
}
@@ -1199,9 +1200,8 @@ void SmParser::Product()
while (TokenInGroup(TGPRODUCT))
{ SmStructureNode *pSNode;
- SmNode *pFirst = m_aNodeStack.top(),
+ SmNode *pFirst = lcl_popOrZero(m_aNodeStack),
*pOper;
- m_aNodeStack.pop();
bool bSwitchArgs = false;
SmTokenType eType = m_aCurToken.eType;
@@ -1223,8 +1223,7 @@ void SmParser::Product()
m_aCurToken.nGroup = TGPRODUCT;
GlyphSpecial();
- pOper = m_aNodeStack.top();
- m_aNodeStack.pop();
+ pOper = lcl_popOrZero(m_aNodeStack);
break;
case TOVERBRACE :
@@ -1253,8 +1252,7 @@ void SmParser::Product()
pSNode = new SmBinHorNode(m_aCurToken);
OpSubSup();
- pOper = m_aNodeStack.top();
- m_aNodeStack.pop();
+ pOper = lcl_popOrZero(m_aNodeStack);
}
Power();
@@ -1262,13 +1260,11 @@ void SmParser::Product()
if (bSwitchArgs)
{
//! vgl siehe SmBinDiagonalNode::Arrange
- pSNode->SetSubNodes(pFirst, m_aNodeStack.top(), pOper);
- m_aNodeStack.pop();
+ pSNode->SetSubNodes(pFirst, lcl_popOrZero(m_aNodeStack), pOper);
}
else
{
- pSNode->SetSubNodes(pFirst, pOper, m_aNodeStack.top());
- m_aNodeStack.pop();
+ pSNode->SetSubNodes(pFirst, pOper, lcl_popOrZero(m_aNodeStack));
}
m_aNodeStack.push(pSNode);
}
@@ -1295,8 +1291,7 @@ void SmParser::SubSup(sal_uLong nActiveGroup)
// initialize subnodes array
SmNodeArray aSubNodes;
aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES);
- aSubNodes[0] = m_aNodeStack.top();
- m_aNodeStack.pop();
+ aSubNodes[0] = lcl_popOrZero(m_aNodeStack);
for (sal_uInt16 i = 1; i < aSubNodes.size(); i++)
aSubNodes[i] = NULL;
@@ -1336,8 +1331,7 @@ void SmParser::SubSup(sal_uLong nActiveGroup)
// set sub-/supscript if not already done
if (aSubNodes[nIndex] != NULL)
Error(PE_DOUBLE_SUBSUPSCRIPT);
- aSubNodes[nIndex] = m_aNodeStack.top();
- m_aNodeStack.pop();
+ aSubNodes[nIndex] = lcl_popOrZero(m_aNodeStack);
}
pNode->SetSubNodes(aSubNodes);
@@ -1544,18 +1538,18 @@ void SmParser::Term()
else
FontAttribut();
+ SmNode* pTmp = lcl_popOrZero(m_aNodeStack);
+
// check if casting in following line is ok
- OSL_ENSURE(!m_aNodeStack.top()->IsVisible(), "Sm : Ooops...");
+ OSL_ENSURE(pTmp && !pTmp->IsVisible(), "Sm : Ooops...");
- aArray[n] = (SmStructureNode *) m_aNodeStack.top();
- m_aNodeStack.pop();
+ aArray[n] = (SmStructureNode *) pTmp;
n++;
}
Power();
- SmNode *pFirstNode = m_aNodeStack.top();
- m_aNodeStack.pop();
+ SmNode *pFirstNode = lcl_popOrZero(m_aNodeStack);
while (n > 0)
{ aArray[n - 1]->SetSubNodes(0, pFirstNode);
pFirstNode = aArray[n - 1];
@@ -1577,8 +1571,7 @@ void SmParser::Term()
//
Function();
- SmNode *pFunc = m_aNodeStack.top();
- m_aNodeStack.pop();
+ SmNode *pFunc = lcl_popOrZero(m_aNodeStack);
if (m_aCurToken.eType == TLPARENT)
{ Term();
@@ -1591,8 +1584,7 @@ void SmParser::Term()
Insert('}', GetTokenIndex());
SmStructureNode *pSNode = new SmExpressionNode(pFunc->GetToken());
- pSNode->SetSubNodes(pFunc, m_aNodeStack.top());
- m_aNodeStack.pop();
+ pSNode->SetSubNodes(pFunc, lcl_popOrZero(m_aNodeStack));
m_aNodeStack.push(pSNode);
}
}
@@ -1650,14 +1642,12 @@ void SmParser::Operator()
if (TokenInGroup(TGLIMIT) || TokenInGroup(TGPOWER))
SubSup(m_aCurToken.nGroup);
- SmNode *pOperator = m_aNodeStack.top();
- m_aNodeStack.pop();
+ SmNode *pOperator = lcl_popOrZero(m_aNodeStack);
// get argument
Power();
- pSNode->SetSubNodes(pOperator, m_aNodeStack.top());
- m_aNodeStack.pop();
+ pSNode->SetSubNodes(pOperator, lcl_popOrZero(m_aNodeStack));
m_aNodeStack.push(pSNode);
}
}
@@ -1745,8 +1735,7 @@ void SmParser::UnOper()
case TNROOT :
NextToken();
Power();
- pExtra = m_aNodeStack.top();
- m_aNodeStack.pop();
+ pExtra = lcl_popOrZero(m_aNodeStack);
break;
case TUOPER :
@@ -1755,8 +1744,7 @@ void SmParser::UnOper()
m_aCurToken.eType = TUOPER;
m_aCurToken.nGroup = TGUNOPER;
GlyphSpecial();
- pOper = m_aNodeStack.top();
- m_aNodeStack.pop();
+ pOper = lcl_popOrZero(m_aNodeStack);
break;
case TPLUS :
@@ -1766,8 +1754,7 @@ void SmParser::UnOper()
case TNEG :
case TFACT :
OpSubSup();
- pOper = m_aNodeStack.top();
- m_aNodeStack.pop();
+ pOper = lcl_popOrZero(m_aNodeStack);
break;
default :
@@ -1776,8 +1763,7 @@ void SmParser::UnOper()
// get argument
Power();
- pArg = m_aNodeStack.top();
- m_aNodeStack.pop();
+ pArg = lcl_popOrZero(m_aNodeStack);
if (eType == TABS)
{ pSNode = new SmBraceNode(aNodeToken);
@@ -2041,8 +2027,7 @@ void SmParser::Brace()
NextToken();
Bracebody(true);
- pBody = m_aNodeStack.top();
- m_aNodeStack.pop();
+ pBody = lcl_popOrZero(m_aNodeStack);
if (m_aCurToken.eType == TRIGHT)
{ NextToken();
@@ -2070,8 +2055,7 @@ void SmParser::Brace()
NextToken();
Bracebody(false);
- pBody = m_aNodeStack.top();
- m_aNodeStack.pop();
+ pBody = lcl_popOrZero(m_aNodeStack);
SmTokenType eExpectedType = TUNKNOWN;
switch (pLeft->GetToken().eType)
@@ -2168,8 +2152,7 @@ void SmParser::Bracebody(bool bIsLeftRight)
aNodes.resize(nNum);
for (sal_uInt16 i = 0; i < nNum; i++)
{
- aNodes[nNum - 1 - i] = m_aNodeStack.top();
- m_aNodeStack.pop();
+ aNodes[nNum - 1 - i] = lcl_popOrZero(m_aNodeStack);
}
pBody->SetSubNodes(aNodes);
@@ -2229,8 +2212,7 @@ void SmParser::Binom()
for (int i = 0; i < 2; i++)
{
- ExpressionArray[2 - (i + 1)] = m_aNodeStack.top();
- m_aNodeStack.pop();
+ ExpressionArray[2 - (i + 1)] = lcl_popOrZero(m_aNodeStack);
}
pSNode->SetSubNodes(ExpressionArray);
@@ -2258,8 +2240,7 @@ void SmParser::Stack()
for (sal_uInt16 i = 0; i < n; i++)
{
- ExpressionArray[n - (i + 1)] = m_aNodeStack.top();
- m_aNodeStack.pop();
+ ExpressionArray[n - (i + 1)] = lcl_popOrZero(m_aNodeStack);
}
if (m_aCurToken.eType != TRGROUP)
@@ -2325,8 +2306,7 @@ void SmParser::Matrix()
for (sal_uInt16 i = 0; i < (nRC); i++)
{
- ExpressionArray[(nRC) - (i + 1)] = m_aNodeStack.top();
- m_aNodeStack.pop();
+ ExpressionArray[(nRC) - (i + 1)] = lcl_popOrZero(m_aNodeStack);
}
if (m_aCurToken.eType != TRGROUP)
@@ -2482,8 +2462,7 @@ SmNode *SmParser::Parse(const String &rBuffer)
NextToken();
Table();
- SmNode* result = m_aNodeStack.top();
- m_aNodeStack.pop();
+ SmNode* result = lcl_popOrZero(m_aNodeStack);
return result;
}
@@ -2508,8 +2487,7 @@ SmNode *SmParser::ParseExpression(const String &rBuffer)
NextToken();
Expression();
- SmNode* result = m_aNodeStack.top();
- m_aNodeStack.pop();
+ SmNode* result = lcl_popOrZero(m_aNodeStack);
return result;
}