[muparser] Remove m_nIfElseCounter instance variable

No idea why this isn't just a local.
This commit is contained in:
ridiculousfish 2017-12-18 09:34:53 -08:00
parent 4452d9ce18
commit ab95f94048
2 changed files with 5 additions and 9 deletions

View File

@ -270,9 +270,6 @@ class ParserBase {
string_type m_sOprtChars; ///< Charset for postfix/ binary operator tokens string_type m_sOprtChars; ///< Charset for postfix/ binary operator tokens
string_type m_sInfixOprtChars; ///< Charset for infix operator tokens string_type m_sInfixOprtChars; ///< Charset for infix operator tokens
mutable int
m_nIfElseCounter; ///< Internal counter for keeping track of nested if-then-else clauses
// items merely used for caching state information // items merely used for caching state information
mutable valbuf_type mutable valbuf_type
m_vStackBuffer; ///< This is merely a buffer used for the stack in the cmd parsing routine m_vStackBuffer; ///< This is merely a buffer used for the stack in the cmd parsing routine

View File

@ -79,7 +79,6 @@ ParserBase::ParserBase()
m_sNameChars(), m_sNameChars(),
m_sOprtChars(), m_sOprtChars(),
m_sInfixOprtChars(), m_sInfixOprtChars(),
m_nIfElseCounter(0),
m_vStackBuffer(), m_vStackBuffer(),
m_nFinalResultIdx(0) { m_nFinalResultIdx(0) {
InitTokenReader(); InitTokenReader();
@ -144,7 +143,6 @@ void ParserBase::ReInit() const {
m_vStringBuf.clear(); m_vStringBuf.clear();
m_vRPN.clear(); m_vRPN.clear();
m_pTokenReader->ReInit(); m_pTokenReader->ReInit();
m_nIfElseCounter = 0;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -1003,6 +1001,7 @@ ValueOrError ParserBase::ExecuteRPN() const {
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
OptionalError ParserBase::CreateRPN() const { OptionalError ParserBase::CreateRPN() const {
if (!m_pTokenReader->GetExpr().length()) return ParserError(ecUNEXPECTED_EOF, 0); if (!m_pTokenReader->GetExpr().length()) return ParserError(ecUNEXPECTED_EOF, 0);
int ifElseCounter = 0;
ParserStack<token_type> stOpt, stVal; ParserStack<token_type> stOpt, stVal;
ParserStack<int> stArgCount; ParserStack<int> stArgCount;
@ -1044,8 +1043,8 @@ OptionalError ParserBase::CreateRPN() const {
} }
case cmELSE: case cmELSE:
m_nIfElseCounter--; ifElseCounter--;
if (m_nIfElseCounter < 0) return Error(ecMISPLACED_COLON, m_pTokenReader->GetPos()); if (ifElseCounter < 0) return Error(ecMISPLACED_COLON, m_pTokenReader->GetPos());
oerr = ApplyRemainingOprt(stOpt, stVal); oerr = ApplyRemainingOprt(stOpt, stVal);
if (oerr.has_error()) return oerr.error(); if (oerr.has_error()) return oerr.error();
@ -1111,7 +1110,7 @@ OptionalError ParserBase::CreateRPN() const {
// case cmOR: // case cmOR:
// case cmXOR: // case cmXOR:
case cmIF: case cmIF:
m_nIfElseCounter++; ifElseCounter++;
// fallthrough intentional (no break!) // fallthrough intentional (no break!)
case cmLAND: case cmLAND:
@ -1203,7 +1202,7 @@ OptionalError ParserBase::CreateRPN() const {
if (ParserBase::g_DbgDumpCmdCode) m_vRPN.AsciiDump(); if (ParserBase::g_DbgDumpCmdCode) m_vRPN.AsciiDump();
if (m_nIfElseCounter > 0) return Error(ecMISSING_ELSE_CLAUSE); if (ifElseCounter > 0) return Error(ecMISSING_ELSE_CLAUSE);
// get the last value (= final result) from the stack // get the last value (= final result) from the stack
assert(stArgCount.size() == 1 && "Expected arg count of 1"); assert(stArgCount.size() == 1 && "Expected arg count of 1");