From e728bf45de04adb1c52c6b925dee743041fc28f6 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Mon, 18 Dec 2017 11:38:55 -0800 Subject: [PATCH] [muparser] Remove m_strFormula from the ParserError --- muparser-2.2.5/include/muParserDef.h | 4 +- muparser-2.2.5/samples/example1/example1.cpp | 56 -------------------- muparser-2.2.5/src/muParserBase.cpp | 2 +- muparser-2.2.5/src/muParserError.cpp | 19 ++----- muparser-2.2.5/src/muParserTest.cpp | 2 +- 5 files changed, 7 insertions(+), 76 deletions(-) diff --git a/muparser-2.2.5/include/muParserDef.h b/muparser-2.2.5/include/muParserDef.h index 0c7e023aa..126616dc2 100644 --- a/muparser-2.2.5/include/muParserDef.h +++ b/muparser-2.2.5/include/muParserDef.h @@ -308,8 +308,7 @@ class ParserError { ParserError(); explicit ParserError(EErrorCodes a_iErrc); explicit ParserError(const string_type &sMsg); - ParserError(EErrorCodes a_iErrc, const string_type &sTok, - const string_type &sFormula = string_type(), int a_iPos = -1); + ParserError(EErrorCodes a_iErrc, const string_type &sTok, int a_iPos = -1); ParserError(EErrorCodes a_iErrc, int a_iPos, const string_type &sTok); ParserError(const char_type *a_szMsg, int a_iPos = -1, const string_type &sTok = string_type()); ParserError(ParserError &&) = default; @@ -327,7 +326,6 @@ class ParserError { private: string_type m_strMsg; ///< The message string - string_type m_strFormula; ///< Formula string string_type m_strTok; ///< Token related with the error int m_iPos = -1; ///< Formula position related to the error EErrorCodes m_iErrc = ecUNDEFINED; ///< Error code diff --git a/muparser-2.2.5/samples/example1/example1.cpp b/muparser-2.2.5/samples/example1/example1.cpp index 398b7f980..3d9332d7a 100644 --- a/muparser-2.2.5/samples/example1/example1.cpp +++ b/muparser-2.2.5/samples/example1/example1.cpp @@ -187,61 +187,6 @@ ValueOrError Help() { return 0; } -//--------------------------------------------------------------------------- -/* -void CheckLocale() -{ - // Local names: - // "C" - the classic C locale - // "de_DE" - not for Windows? - // "en_US" - not for Windows? - // "German_germany" - For MSVC8 - try - { - std::locale loc("German_germany"); - console() << _T("Locale settings:\n"); - console() << _T(" Decimal point: '") << std::use_facet ->(loc).decimal_point() << _T("'\n"); - console() << _T(" Thousands sep: '") << std::use_facet ->(loc).thousands_sep() << _T("'\n"); - console() << _T(" Grouping: '") << std::use_facet >(loc).grouping() -<< _T("'\n"); - console() << _T(" True is named: '") << std::use_facet >(loc).truename() -<< _T("'\n"); - console() << _T(" False is named: '") << std::use_facet >(loc).falsename() -<< _T("'\n"); - console() << _T("-----------------------------------------------------------\n"); - } - catch(...) - { - console() << _T("Locale settings:\n"); - console() << _T(" invalid locale name\n"); - console() << _T("-----------------------------------------------------------\n"); - } -} - -//--------------------------------------------------------------------------- -void CheckDiff() -{ - mu::Parser parser; - value_type x = 1, - v1, - v2, - v3, - eps(pow(std::numeric_limits::epsilon(), 0.2)); - parser.DefineVar(_T("x"), &x); - parser.SetExpr(_T("_e^-x*sin(x)")); - - v1 = parser.Diff(&x, 1), - v2 = parser.Diff(&x, 1, eps); - v3 = cos((value_type)1.0)/exp((value_type)1) - sin((value_type)1.0)/exp((value_type)1); -//-0.110793765307; - mu::console() << parser.GetExpr() << _T("\n"); - mu::console() << _T("v1 = ") << v1 << _T("; v1-v3 = ") << v1-v3 << _T("\n"); - mu::console() << _T("v2 = ") << v2 << _T("; v2-v3 = ") << v2-v3 << _T("\n"); -} -*/ - //--------------------------------------------------------------------------- /** \brief Check for external keywords. */ @@ -371,7 +316,6 @@ void Calc() { mu::console() << _T("\nError:\n"); mu::console() << _T("------\n"); mu::console() << _T("Message: ") << e.GetMsg() << _T("\n"); - mu::console() << _T("Expression: \"") << e.GetExpr() << _T("\"\n"); mu::console() << _T("Token: \"") << e.GetToken() << _T("\"\n"); mu::console() << _T("Position: ") << (int)e.GetPos() << _T("\n"); mu::console() << _T("Errc: ") << std::dec << e.GetCode() << _T("\n"); diff --git a/muparser-2.2.5/src/muParserBase.cpp b/muparser-2.2.5/src/muParserBase.cpp index 8ce9ffe46..6d02c6f3c 100644 --- a/muparser-2.2.5/src/muParserBase.cpp +++ b/muparser-2.2.5/src/muParserBase.cpp @@ -1130,7 +1130,7 @@ ValueOrError ParserBase::BuildAndExecuteRPN() const { \param a_strTok [in] The token string representation associated with the error. */ ParserError ParserBase::Error(EErrorCodes a_iErrc, int a_iPos, const string_type &a_sTok) const { - return ParserError(a_iErrc, a_sTok, m_pTokenReader->GetExpr(), a_iPos); + return ParserError(a_iErrc, a_sTok, a_iPos); } //------------------------------------------------------------------------------ diff --git a/muparser-2.2.5/src/muParserError.cpp b/muparser-2.2.5/src/muParserError.cpp index 099ebe825..f02be129d 100644 --- a/muparser-2.2.5/src/muParserError.cpp +++ b/muparser-2.2.5/src/muParserError.cpp @@ -142,12 +142,10 @@ ParserError::ParserError(const string_type &sMsg) { /** \brief Construct an error object. \param [in] a_iErrc the error code. \param [in] sTok The token string related to this error. - \param [in] sExpr The expression related to the error. \param [in] a_iPos the position in the expression where the error occurred. */ -ParserError::ParserError(EErrorCodes iErrc, const string_type &sTok, const string_type &sExpr, - int iPos) - : m_strMsg(), m_strFormula(sExpr), m_strTok(sTok), m_iPos(iPos), m_iErrc(iErrc) { +ParserError::ParserError(EErrorCodes iErrc, const string_type &sTok, int iPos) + : m_strTok(sTok), m_iPos(iPos), m_iErrc(iErrc) { m_strMsg = parser_error_for_code(m_iErrc); stringstream_type stream; stream << (int)m_iPos; @@ -162,7 +160,7 @@ ParserError::ParserError(EErrorCodes iErrc, const string_type &sTok, const strin \param [in] sTok The token string related to this error. */ ParserError::ParserError(EErrorCodes iErrc, int iPos, const string_type &sTok) - : m_strMsg(), m_strFormula(), m_strTok(sTok), m_iPos(iPos), m_iErrc(iErrc) { + : m_strMsg(), m_strTok(sTok), m_iPos(iPos), m_iErrc(iErrc) { m_strMsg = parser_error_for_code(m_iErrc); stringstream_type stream; stream << (int)m_iPos; @@ -177,7 +175,7 @@ ParserError::ParserError(EErrorCodes iErrc, int iPos, const string_type &sTok) \param [in] sTok The token string related to this error. */ ParserError::ParserError(const char_type *szMsg, int iPos, const string_type &sTok) - : m_strMsg(szMsg), m_strFormula(), m_strTok(sTok), m_iPos(iPos), m_iErrc(ecGENERIC) { + : m_strMsg(szMsg), m_strTok(sTok), m_iPos(iPos), m_iErrc(ecGENERIC) { stringstream_type stream; stream << (int)m_iPos; ReplaceSubString(m_strMsg, _T("$POS$"), stream.str()); @@ -214,20 +212,11 @@ void ParserError::ReplaceSubString(string_type &strSource, const string_type &st /** \brief Reset the erro object. */ void ParserError::Reset() { m_strMsg = _T(""); - m_strFormula = _T(""); m_strTok = _T(""); m_iPos = -1; m_iErrc = ecUNDEFINED; } -//------------------------------------------------------------------------------ -/** \brief Set the expression related to this error. */ -void ParserError::SetFormula(const string_type &a_strFormula) { m_strFormula = a_strFormula; } - -//------------------------------------------------------------------------------ -/** \brief gets the expression related tp this error.*/ -const string_type &ParserError::GetExpr() const { return m_strFormula; } - //------------------------------------------------------------------------------ /** \brief Returns the message string for this error. */ const string_type &ParserError::GetMsg() const { return m_strMsg; } diff --git a/muparser-2.2.5/src/muParserTest.cpp b/muparser-2.2.5/src/muParserTest.cpp index 6a05f5981..b1e66577b 100644 --- a/muparser-2.2.5/src/muParserTest.cpp +++ b/muparser-2.2.5/src/muParserTest.cpp @@ -1202,7 +1202,7 @@ int ParserTester::EqnTestInt(const string_type &a_str, double a_fRes, bool a_fPa } } catch (Parser::exception_type &e) { if (a_fPass) { - mu::console() << _T("\n fail: ") << e.GetExpr() << _T(" : ") << e.GetMsg(); + mu::console() << _T("\n fail: ") << e.GetMsg(); iRet = 1; } } catch (...) {