mirror of
https://github.com/weechat/weechat.git
synced 2026-07-04 00:33:13 +02:00
core: evaluate left/right part of comparison after split on the comparison operator in ${if:xxx} (closes #1627)
To force evaluation of the expression before doing the comparison (less safe),
the "${eval_cond:xxx}" can be used.
With the old behavior we had:
>> ${if:a==b}
== [0]
>> ${if:${raw:a==b}}
== [0]
>> ${if:${eval_cond:${raw:a==b}}}
== [0]
And with the new behavior, we have:
>> ${if:a==b}
== [0]
>> ${if:${raw:a==b}}
== [1]
>> ${if:${eval_cond:${raw:a==b}}}
== [0]
This commit is contained in:
+3
-6
@@ -666,7 +666,7 @@ char *
|
||||
eval_string_if (const char *text, struct t_eval_context *eval_context)
|
||||
{
|
||||
const char *pos, *pos2;
|
||||
char *value, *condition, *tmp, *tmp2;
|
||||
char *value, *condition, *tmp;
|
||||
int rc;
|
||||
|
||||
value = NULL;
|
||||
@@ -679,13 +679,10 @@ eval_string_if (const char *text, struct t_eval_context *eval_context)
|
||||
strndup (text, pos - text) : strdup (text);
|
||||
if (!condition)
|
||||
return strdup ("");
|
||||
tmp = eval_replace_vars (condition, eval_context);
|
||||
tmp2 = eval_expression_condition ((tmp) ? tmp : "", eval_context);
|
||||
rc = eval_is_true (tmp2);
|
||||
tmp = eval_expression_condition (condition, eval_context);
|
||||
rc = eval_is_true (tmp);
|
||||
if (tmp)
|
||||
free (tmp);
|
||||
if (tmp2)
|
||||
free (tmp2);
|
||||
if (rc)
|
||||
{
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user