core: fix evaluation of condition when the left operand is an empty string
This commit is contained in:
parent
97ad48e317
commit
6bf0dfddd6
@ -28,6 +28,7 @@ New features::
|
||||
|
||||
Bug fixes::
|
||||
|
||||
* core: fix evaluation of condition when the left operand is an empty string
|
||||
* core: fix string evaluation with regex replacement when the string is empty
|
||||
* core: fix check of tags in lines (command /filter and hook_print)
|
||||
* core: fix clear of completion item in case of partial completion (issue #1162)
|
||||
|
@ -962,14 +962,21 @@ eval_expression_condition (const char *expr,
|
||||
for (comp = 0; comp < EVAL_NUM_COMPARISONS; comp++)
|
||||
{
|
||||
pos = eval_strstr_level (expr2, comparisons[comp], "(", ")", 0);
|
||||
if (pos > expr2)
|
||||
if (pos >= expr2)
|
||||
{
|
||||
pos_end = pos - 1;
|
||||
while ((pos_end > expr2) && (pos_end[0] == ' '))
|
||||
if (pos > expr2)
|
||||
{
|
||||
pos_end--;
|
||||
pos_end = pos - 1;
|
||||
while ((pos_end > expr2) && (pos_end[0] == ' '))
|
||||
{
|
||||
pos_end--;
|
||||
}
|
||||
sub_expr = string_strndup (expr2, pos_end + 1 - expr2);
|
||||
}
|
||||
else
|
||||
{
|
||||
sub_expr = strdup ("");
|
||||
}
|
||||
sub_expr = string_strndup (expr2, pos_end + 1 - expr2);
|
||||
if (!sub_expr)
|
||||
goto end;
|
||||
pos += strlen (comparisons[comp]);
|
||||
|
@ -96,6 +96,7 @@ TEST(CoreEval, EvalCondition)
|
||||
WEE_CHECK_EVAL("0", "");
|
||||
WEE_CHECK_EVAL("0", "0");
|
||||
WEE_CHECK_EVAL("0", "1 == 2");
|
||||
WEE_CHECK_EVAL("0", "==1");
|
||||
WEE_CHECK_EVAL("0", "1 >= 2");
|
||||
WEE_CHECK_EVAL("0", "2 <= 1");
|
||||
WEE_CHECK_EVAL("0", "2 != 2");
|
||||
@ -115,6 +116,7 @@ TEST(CoreEval, EvalCondition)
|
||||
WEE_CHECK_EVAL("0", "0xA3 < 2");
|
||||
WEE_CHECK_EVAL("0", "-0xA3 > 2");
|
||||
WEE_CHECK_EVAL("0", "1 == 5 > 18");
|
||||
WEE_CHECK_EVAL("0", ">1");
|
||||
WEE_CHECK_EVAL("0", "abc == def");
|
||||
WEE_CHECK_EVAL("0", "()");
|
||||
WEE_CHECK_EVAL("0", "(5 > 26)");
|
||||
@ -133,6 +135,7 @@ TEST(CoreEval, EvalCondition)
|
||||
WEE_CHECK_EVAL("0", "((0 || 1) && 1) && 0");
|
||||
WEE_CHECK_EVAL("0", "abcd =~ (?-i)^ABC");
|
||||
WEE_CHECK_EVAL("0", "abcd =~ \\(abcd\\)");
|
||||
WEE_CHECK_EVAL("0", "=~abcd");
|
||||
WEE_CHECK_EVAL("0", "(abcd) =~ \\(\\(abcd\\)\\)");
|
||||
WEE_CHECK_EVAL("0", "abcd =* abce");
|
||||
WEE_CHECK_EVAL("0", "abcd =* a*e");
|
||||
@ -148,6 +151,7 @@ TEST(CoreEval, EvalCondition)
|
||||
WEE_CHECK_EVAL("1", "123");
|
||||
WEE_CHECK_EVAL("1", "abc");
|
||||
WEE_CHECK_EVAL("1", "2 == 2");
|
||||
WEE_CHECK_EVAL("1", "==0");
|
||||
WEE_CHECK_EVAL("1", "2 >= 1");
|
||||
WEE_CHECK_EVAL("1", "1 <= 2");
|
||||
WEE_CHECK_EVAL("1", "1 != 2");
|
||||
@ -171,6 +175,7 @@ TEST(CoreEval, EvalCondition)
|
||||
WEE_CHECK_EVAL("1", "(26 > 5)");
|
||||
WEE_CHECK_EVAL("1", "((26 > 5))");
|
||||
WEE_CHECK_EVAL("1", "(5 < 26)");
|
||||
WEE_CHECK_EVAL("1", "<1");
|
||||
WEE_CHECK_EVAL("1", "def > abc");
|
||||
WEE_CHECK_EVAL("1", "1 && 1");
|
||||
WEE_CHECK_EVAL("1", "abc && 1");
|
||||
@ -184,6 +189,9 @@ TEST(CoreEval, EvalCondition)
|
||||
WEE_CHECK_EVAL("1", "((0 || 1) && 1) && 1");
|
||||
WEE_CHECK_EVAL("1", "abcd =~ ^ABC");
|
||||
WEE_CHECK_EVAL("1", "abcd =~ (?-i)^abc");
|
||||
WEE_CHECK_EVAL("1", "abcd=~abc");
|
||||
WEE_CHECK_EVAL("1", "=~");
|
||||
WEE_CHECK_EVAL("1", "abc=~");
|
||||
WEE_CHECK_EVAL("1", "(abcd) =~ (abcd)");
|
||||
WEE_CHECK_EVAL("1", "(abcd) =~ \\(abcd\\)");
|
||||
WEE_CHECK_EVAL("1", "((abcd)) =~ \\(\\(abcd\\)\\)");
|
||||
|
Loading…
x
Reference in New Issue
Block a user