summaryrefslogtreecommitdiff
path: root/formula
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-15 09:04:38 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-15 19:25:23 +0200
commit4cc702a7055c0e12c7cbf5e5e359e7cbc8b88020 (patch)
treef09f7167cdca22f16edb5a998c2f9714e4bdc698 /formula
parent393aa2b3dee9cca84a215635060b369a962ab179 (diff)
loplugin:buriedassign in f,h,i*
Change-Id: Iac753e528e13cb2565832a484e87f88061bbc91e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92239 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'formula')
-rw-r--r--formula/source/core/api/FormulaCompiler.cxx16
-rw-r--r--formula/source/core/api/token.cxx16
2 files changed, 19 insertions, 13 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index e8c92c990509..f6f7e4876eb0 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -1396,17 +1396,19 @@ void FormulaCompiler::Factor()
eOp = Expression();
// Do not ignore error here, regardless of mbStopOnError, to not
// change the formula expression in case of an unexpected state.
- if (pArr->GetCodeError() == FormulaError::NONE)
+ if (pArr->GetCodeError() == FormulaError::NONE && pc >= 2)
{
// Left and right operands must be reference or function
// returning reference to form a range list.
- const FormulaToken* p;
- if (pc >= 2
- && ((p = pCode[-2]) != nullptr) && isPotentialRangeType( p, true, false)
- && ((p = pCode[-1]) != nullptr) && isPotentialRangeType( p, true, true))
+ const FormulaToken* p = pCode[-2];
+ if (p && isPotentialRangeType( p, true, false))
{
- pFacToken->NewOpCode( ocUnion, FormulaToken::PrivateAccess());
- PutCode( pFacToken);
+ p = pCode[-1];
+ if (p && isPotentialRangeType( p, true, true))
+ {
+ pFacToken->NewOpCode( ocUnion, FormulaToken::PrivateAccess());
+ PutCode( pFacToken);
+ }
}
}
}
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index 54d0b52eb4b5..0b8b373a9de3 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -1392,9 +1392,12 @@ FormulaTokenArray * FormulaTokenArray::RewriteMissing( const MissingConvention &
OpCode eOp;
if (rConv.isPODF() && pCtx[ nFn ].mpFunc && pCtx[ nFn ].mpFunc->GetOpCode() == ocAddress)
pOcas[ nOcas++ ] = nFn; // entering ADDRESS() if PODF
- else if ((rConv.isODFF() || rConv.isOOXML()) && pCtx[ nFn ].mpFunc &&
- ((eOp = pCtx[ nFn ].mpFunc->GetOpCode()) == ocDBCount || eOp == ocDBCount2))
- pOcds[ nOcds++ ] = nFn; // entering DCOUNT() or DCOUNTA() if ODFF or OOXML
+ else if ((rConv.isODFF() || rConv.isOOXML()) && pCtx[ nFn ].mpFunc)
+ {
+ eOp = pCtx[ nFn ].mpFunc->GetOpCode();
+ if (eOp == ocDBCount || eOp == ocDBCount2)
+ pOcds[ nOcds++ ] = nFn; // entering DCOUNT() or DCOUNTA() if ODFF or OOXML
+ }
}
break;
case ocClose:
@@ -1608,10 +1611,11 @@ const FormulaToken* FormulaTokenIterator::PeekNextOperator()
{
const FormulaToken* t = nullptr;
short nIdx = maStack.back().nPC;
- while (!t && ((t = GetNonEndOfPathToken( ++nIdx)) != nullptr))
+ for (;;)
{
- if (t->GetOpCode() == ocPush)
- t = nullptr; // ignore operands
+ t = GetNonEndOfPathToken( ++nIdx);
+ if (t == nullptr || t->GetOpCode() != ocPush)
+ break; // ignore operands
}
if (!t && maStack.size() > 1)
{