Skip to content

Commit

Permalink
fix for #125
Browse files Browse the repository at this point in the history
added unit test for #123
  • Loading branch information
beltoforion committed Aug 11, 2023
1 parent 29815f8 commit 2bcd2ef
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
History:
--------

Rev 2.3.5: 07.03.2023
Rev 2.3.5: 11.08.2023
---------------------
Bugfixes:
* Fix for #125 (bug in muParserDLL.cpp / mupDefineInfixOprt)

Changes:
* Bitwise "and" and "or" used the same precedence. (Now bitwise and priority is higher, like in C++)

Expand Down
13 changes: 8 additions & 5 deletions include/muParserDLL.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
| Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/
|__|_| /____/| __(____ /__| /____ >\___ >__|
\/ |__| \/ \/ \/
Copyright (C) 2004 - 2022 Ingo Berg
Copyright (C) 2004 - 2023 Ingo Berg
Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:
Expand Down Expand Up @@ -254,10 +254,13 @@ extern "C"
muBool_t a_bOptimize);


API_EXPORT(void) mupDefineInfixOprt(muParserHandle_t a_hParser,
const muChar_t* a_szName,
muFun1_t a_pOprt,
muBool_t a_bOptimize);
// signature changed to fix #125 (https://github.com/beltoforion/muparser/issues/125)
API_EXPORT(void) mupDefineInfixOprt(
muParserHandle_t a_hParser,
const muChar_t* a_szName,
muFun1_t a_pOprt,
int a_iPrec,
muBool_t a_bAllowOpt);

// Define character sets for identifiers
API_EXPORT(void) mupDefineNameChars(muParserHandle_t a_hParser, const muChar_t* a_szCharset);
Expand Down
2 changes: 1 addition & 1 deletion include/muParserDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ namespace mu
static const int MaxLenExpression = 20000;
static const int MaxLenIdentifier = 100;
static const string_type ParserVersion = string_type(_T("2.3.4 (Develop)"));
static const string_type ParserVersionDate = string_type(_T("20230307"));
static const string_type ParserVersionDate = string_type(_T("20230811"));
} // end of namespace

#if defined(_MSC_VER)
Expand Down
5 changes: 3 additions & 2 deletions samples/example2/example2.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
| Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/
|__|_| /____/| __(____ /__| /____ >\___ >__|
\/ |__| \/ \/ \/
Copyright (C) 2004 - 2021 Ingo Berg
Copyright (C) 2004 - 2023 Ingo Berg
Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:
Expand All @@ -30,6 +30,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <wchar.h>
#include <inttypes.h>

Expand Down Expand Up @@ -406,7 +407,7 @@ static void Calc(void)
mupDefinePostfixOprt(hParser, _T("m"), Milli, 0);

// Define infix operator [optional]
mupDefineInfixOprt(hParser, _T("!"), Not, 0);
mupDefineInfixOprt(hParser, _T("!"), Not, 0, true);

// Define functions [optional]
// mupDefineStrFun(hParser, "query", SampleQuery, 0); // Add an unoptimizeable function
Expand Down
6 changes: 3 additions & 3 deletions src/muParserDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,12 +895,12 @@ API_EXPORT(void) mupDefinePostfixOprt(muParserHandle_t a_hParser, const muChar_t
MU_CATCH
}


API_EXPORT(void) mupDefineInfixOprt(muParserHandle_t a_hParser, const muChar_t* a_szName, muFun1_t a_pOprt, muBool_t a_bAllowOpt)
// Signature changed to fix #125 (https://github.com/beltoforion/muparser/issues/125)
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_bAllowOpt != 0);
p->DefineInfixOprt(a_szName, a_pOprt, a_iPrec, a_bAllowOpt != 0);
MU_CATCH
}

Expand Down

0 comments on commit 2bcd2ef

Please sign in to comment.