summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2016-10-06 18:17:15 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2016-10-07 04:10:23 +0000
commit33c57f15501dbd05834cd8844e9124b06536e62c (patch)
treed425b0314f9bc54f29888290246b7c4591aee8f7 /starmath
parent8daf6707ef203b26a744140f74d7cd231a25f0dd (diff)
starmath: Simplify code with std::unique_ptr
Change-Id: I2f6f993b92ae7f2f89b2d9d6c89b51d827226a3d Reviewed-on: https://gerrit.libreoffice.org/29554 Reviewed-by: Takeshi Abe <tabe@fixedpoint.jp> Tested-by: Takeshi Abe <tabe@fixedpoint.jp>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/parse.cxx32
1 files changed, 12 insertions, 20 deletions
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 4977a828e282..56023adb10cf 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -1935,9 +1935,7 @@ void SmParser::DoBrace()
assert(m_aCurToken.eType == TLEFT || TokenInGroup(TG::LBrace));
std::unique_ptr<SmStructureNode> pSNode(new SmBraceNode(m_aCurToken));
- SmNode *pBody = nullptr,
- *pLeft = nullptr,
- *pRight = nullptr;
+ std::unique_ptr<SmNode> pBody, pLeft, pRight;
SmScaleMode eScaleMode = SCALE_NONE;
SmParseError eError = PE_NONE;
@@ -1949,11 +1947,11 @@ void SmParser::DoBrace()
// check for left bracket
if (TokenInGroup(TG::LBrace) || TokenInGroup(TG::RBrace))
{
- pLeft = new SmMathSymbolNode(m_aCurToken);
+ pLeft.reset(new SmMathSymbolNode(m_aCurToken));
NextToken();
DoBracebody(true);
- pBody = popOrZero(m_aNodeStack);
+ pBody.reset(popOrZero(m_aNodeStack));
if (m_aCurToken.eType == TRIGHT)
{ NextToken();
@@ -1961,7 +1959,7 @@ void SmParser::DoBrace()
// check for right bracket
if (TokenInGroup(TG::LBrace) || TokenInGroup(TG::RBrace))
{
- pRight = new SmMathSymbolNode(m_aCurToken);
+ pRight.reset(new SmMathSymbolNode(m_aCurToken));
NextToken();
}
else
@@ -1977,11 +1975,11 @@ void SmParser::DoBrace()
{
assert(TokenInGroup(TG::LBrace));
- pLeft = new SmMathSymbolNode(m_aCurToken);
+ pLeft.reset(new SmMathSymbolNode(m_aCurToken));
NextToken();
DoBracebody(false);
- pBody = popOrZero(m_aNodeStack);
+ pBody.reset(popOrZero(m_aNodeStack));
SmTokenType eExpectedType = TUNKNOWN;
switch (pLeft->GetToken().eType)
@@ -2000,29 +1998,23 @@ void SmParser::DoBrace()
if (m_aCurToken.eType == eExpectedType)
{
- pRight = new SmMathSymbolNode(m_aCurToken);
- NextToken();
+ pRight.reset(new SmMathSymbolNode(m_aCurToken));
+ NextToken();
}
else
eError = PE_PARENT_MISMATCH;
}
if (eError == PE_NONE)
- { OSL_ENSURE(pLeft, "Sm: NULL pointer");
- OSL_ENSURE(pRight, "Sm: NULL pointer");
- pSNode->SetSubNodes(pLeft, pBody, pRight);
+ {
+ assert(pLeft);
+ assert(pRight);
+ pSNode->SetSubNodes(pLeft.release(), pBody.release(), pRight.release());
pSNode->SetScaleMode(eScaleMode);
m_aNodeStack.push_front(std::move(pSNode));
}
else
- {
- pSNode.reset();
- delete pBody;
- delete pLeft;
- delete pRight;
-
Error(eError);
- }
}
void SmParser::DoBracebody(bool bIsLeftRight)