C++ Mathematical Expression Library (ExprTk) http://www.partow.net/programming/exprtk/index.html
This commit is contained in:
parent
4614db6acb
commit
3f228b3f86
13
exprtk.hpp
13
exprtk.hpp
|
@ -250,9 +250,12 @@ namespace exprtk
|
||||||
|
|
||||||
inline void cleanup_escapes(std::string& s)
|
inline void cleanup_escapes(std::string& s)
|
||||||
{
|
{
|
||||||
std::string::iterator itr1 = s.begin();
|
typedef std::string::iterator str_itr_t;
|
||||||
std::string::iterator itr2 = s.begin();
|
|
||||||
std::string::iterator end = s.end ();
|
str_itr_t itr1 = s.begin();
|
||||||
|
str_itr_t itr2 = s.begin();
|
||||||
|
str_itr_t end = s.end ();
|
||||||
|
|
||||||
std::size_t removal_count = 0;
|
std::size_t removal_count = 0;
|
||||||
|
|
||||||
while (end != itr1)
|
while (end != itr1)
|
||||||
|
@ -270,7 +273,7 @@ namespace exprtk
|
||||||
case 'n' : (*itr1) = '\n'; break;
|
case 'n' : (*itr1) = '\n'; break;
|
||||||
case 'r' : (*itr1) = '\r'; break;
|
case 'r' : (*itr1) = '\r'; break;
|
||||||
case 't' : (*itr1) = '\t'; break;
|
case 't' : (*itr1) = '\t'; break;
|
||||||
case '0' : parse_hex(itr1,end,(*itr1));
|
case '0' : parse_hex(itr1, end, (*itr1));
|
||||||
removal_count += 3;
|
removal_count += 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2505,7 +2508,7 @@ namespace exprtk
|
||||||
|
|
||||||
while (!is_end(s_itr_))
|
while (!is_end(s_itr_))
|
||||||
{
|
{
|
||||||
if ('\\' == *s_itr_)
|
if (!escaped && ('\\' == *s_itr_))
|
||||||
{
|
{
|
||||||
escaped_found = true;
|
escaped_found = true;
|
||||||
escaped = true;
|
escaped = true;
|
||||||
|
|
|
@ -2266,7 +2266,11 @@ inline bool run_test02()
|
||||||
test_ab<T>("'\\0x30\\n\\0x31\\n\\0x32\\n\\0x33' == '0\\n1\\n2\\n3'" ,"","",T(1.0)),
|
test_ab<T>("'\\0x30\\n\\0x31\\n\\0x32\\n\\0x33' == '0\\n1\\n2\\n3'" ,"","",T(1.0)),
|
||||||
test_ab<T>("('\\0x30' + '') == '0'" ,"","",T(1.0)),
|
test_ab<T>("('\\0x30' + '') == '0'" ,"","",T(1.0)),
|
||||||
test_ab<T>("('\\0x30' + '\\0x31\\0x32') == '012'" ,"","",T(1.0)),
|
test_ab<T>("('\\0x30' + '\\0x31\\0x32') == '012'" ,"","",T(1.0)),
|
||||||
test_ab<T>("('\\0x30' + '\\0x31\\0x32' + '\\0x33\\0x34\\0x35') == '012345'" ,"","",T(1.0))
|
test_ab<T>("('\\0x30' + '\\0x31\\0x32' + '\\0x33\\0x34\\0x35') == '012345'" ,"","",T(1.0)),
|
||||||
|
test_ab<T>("'a\\'\\\\b' == a" ,"a'\\b","",T(1.0)),
|
||||||
|
test_ab<T>("'a\\\\\\'b' == a" ,"a\\'b","",T(1.0)),
|
||||||
|
test_ab<T>("'a\\'\\\\\\\\b' == a" ,"a'\\\\b","",T(1.0)),
|
||||||
|
test_ab<T>("'a\\0x30\\'\\0x31\\\\\\0x32b' == a" ,"a0'1\\2b","",T(1.0))
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::size_t test_list_size = sizeof(test_list) / sizeof(test_ab<T>);
|
static const std::size_t test_list_size = sizeof(test_list) / sizeof(test_ab<T>);
|
||||||
|
@ -2323,10 +2327,14 @@ inline bool run_test02()
|
||||||
|
|
||||||
if (not_equal(expr_result,test.result))
|
if (not_equal(expr_result,test.result))
|
||||||
{
|
{
|
||||||
printf("run_test02() - Computation Error: Expression: [%s]\tExpected: %19.15f\tResult: %19.15f\n",
|
printf("run_test02() - Computation Error: Expression: [%s]\tExpected: %19.15f\tResult: %19.15f\t"
|
||||||
|
"a='%s'\tb='%s'\tc='%s'\n",
|
||||||
test.expr.c_str(),
|
test.expr.c_str(),
|
||||||
(double)test.result,
|
(double)test.result,
|
||||||
(double)expr_result);
|
(double)expr_result,
|
||||||
|
str_a.c_str(),
|
||||||
|
str_b.c_str(),
|
||||||
|
str_c.c_str());
|
||||||
|
|
||||||
result = false;
|
result = false;
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue