bug in muParserDLL.cpp:mupDefineInfixOprt ?
Oxi75 opened this issue · 4 comments
Hello!
I tried to define a binary not and some other binary operators via DLL callbacks. During this I found a wrong behaviour in the order of execution of the operators.
For the operators I'm able to define the precedence but for the infix operators I cannot if I'm using the DLL functions. To my surprise I can define it on class level. So I checked what is used as default precedence when I'm defining a callback via the DLL.
And this is there point where I believe that I found a bug ...:
You set the a_bAllowedOpt as third parameter of p->DefineInfixOprt method but the third parameter should be the precedence.
This is the code; I added the class method definition as comment
API_EXPORT(void) mupDefineInfixOprt(muParserHandle_t a_hParser, const muChar_t* a_szName, muFun1_t a_pOprt, muBool_t a_bAllowOpt)
{
MU_TRY
muParser_t* const p(AsParser(a_hParser));
p->DefineInfixOprt(a_szName, a_pOprt, a_bAllowOpt != 0);
// void ParserBase::DefineInfixOprt(const string_type& a_sName, fun_type1 a_pFun, int a_iPrec, bool a_bAllowOpt)
MU_CATCH
}
With this modification, I'm now able to set the precedence correctly and my "binary not" is now executed as expected.
API_EXPORT(void) mupDefineInfixOprt(muParserHandle_t a_hParser, const muChar_t* a_szName, muFun1_t a_pOprt, int a_iPrec, muBool_t a_bAllowOpt)
{
MU_TRY
muParser_t* const p(AsParser(a_hParser));
p->DefineInfixOprt(a_szName, a_pOprt, a_iPrec, a_bAllowOpt != 0);
MU_CATCH
}
Probably an addition that never made it into the DLL API. Not sure what to do with the Information though because the fix is breaking backwards compatibility.
On a second thaught. I'll just take your fix. Thanks
great to read - thank you! :-)