core: do not remove quotes in arguments of command /eval (closes #1601)
Now, /eval -n -c "a" == "a" returns True instead of False. When quotes were removed, the condition evaluated was: a" == "a (which is False).
This commit is contained in:
parent
a8abfcd7b4
commit
ee9aa28a8c
@ -28,6 +28,7 @@ New features::
|
||||
|
||||
Bug fixes::
|
||||
|
||||
* core: do not remove quotes in arguments of command /eval as they can be part of the evaluated expression/condition (issue #1601)
|
||||
* core: display an error when the buffer is not found with command /command -buffer
|
||||
* exec: fix search of command by identifier
|
||||
* irc: fix completion of commands /halfop and /dehalfop
|
||||
|
@ -2023,7 +2023,7 @@ COMMAND_CALLBACK(debug)
|
||||
COMMAND_CALLBACK(eval)
|
||||
{
|
||||
int i, print_only, split_command, condition, debug, error;
|
||||
char *result, *ptr_args, *expr, **commands;
|
||||
char *result, *ptr_args, **commands;
|
||||
const char **debug_output;
|
||||
struct t_hashtable *pointers, *options;
|
||||
|
||||
@ -2103,36 +2103,31 @@ COMMAND_CALLBACK(eval)
|
||||
|
||||
if (print_only)
|
||||
{
|
||||
expr = string_remove_quotes (ptr_args, "\"");
|
||||
if (expr)
|
||||
result = eval_expression (ptr_args, pointers, NULL, options);
|
||||
gui_chat_printf_date_tags (NULL, 0, "no_log", "\t>> %s", ptr_args);
|
||||
if (result)
|
||||
{
|
||||
result = eval_expression (expr, pointers, NULL, options);
|
||||
gui_chat_printf_date_tags (NULL, 0, "no_log", "\t>> %s", ptr_args);
|
||||
if (result)
|
||||
{
|
||||
gui_chat_printf_date_tags (NULL, 0, "no_log", "\t== %s[%s%s%s]",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
result,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
|
||||
free (result);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_chat_printf_date_tags (NULL, 0, "no_log", "\t== %s<%s%s%s>",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
_("error"),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
|
||||
}
|
||||
free (expr);
|
||||
if (options && debug)
|
||||
{
|
||||
debug_output = hashtable_get (options,
|
||||
"debug_output");
|
||||
if (debug_output)
|
||||
gui_chat_printf (NULL, "%s", debug_output);
|
||||
}
|
||||
gui_chat_printf_date_tags (NULL, 0, "no_log", "\t== %s[%s%s%s]",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
result,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
|
||||
free (result);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_chat_printf_date_tags (NULL, 0, "no_log", "\t== %s<%s%s%s>",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
_("error"),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
|
||||
}
|
||||
if (options && debug)
|
||||
{
|
||||
debug_output = hashtable_get (options,
|
||||
"debug_output");
|
||||
if (debug_output)
|
||||
gui_chat_printf (NULL, "%s", debug_output);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -203,6 +203,8 @@ TEST(CoreEval, EvalCondition)
|
||||
WEE_CHECK_EVAL("1", "-0xA3 < 2");
|
||||
WEE_CHECK_EVAL("1", "1 == 18 > 5");
|
||||
WEE_CHECK_EVAL("1", "abc == abc");
|
||||
WEE_CHECK_EVAL("1", "'abc' == 'abc'");
|
||||
WEE_CHECK_EVAL("1", "\"abc\" == \"abc\"");
|
||||
WEE_CHECK_EVAL("1", "(26 > 5)");
|
||||
WEE_CHECK_EVAL("1", "((26 > 5))");
|
||||
WEE_CHECK_EVAL("1", "(5 < 26)");
|
||||
|
Loading…
x
Reference in New Issue
Block a user