1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 05:16:38 +02:00

core: fix window/buffer pointers used in command /eval

This commit is contained in:
Sébastien Helleu
2014-08-29 19:11:07 +02:00
parent dda2170d94
commit 421c0752d8
2 changed files with 19 additions and 5 deletions
+1
View File
@@ -25,6 +25,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
=== Bugs fixed
* core: fix window/buffer pointers used in command /eval
* core: fix modifier "weechat_print": discard only one line when several lines
are displayed in same message (closes #171)
* core: fix translation of message displayed after /upgrade
+18 -5
View File
@@ -1835,10 +1835,9 @@ COMMAND_CALLBACK(eval)
{
int i, print_only, condition;
char *result, *ptr_args, *expr, **commands;
struct t_hashtable *options;
struct t_hashtable *pointers, *options;
/* make C compiler happy */
(void) buffer;
(void) data;
(void) argv;
@@ -1870,12 +1869,24 @@ COMMAND_CALLBACK(eval)
if (ptr_args)
{
pointers = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER,
NULL,
NULL);
if (pointers)
{
hashtable_set (pointers, "window",
gui_window_search_with_buffer (buffer));
hashtable_set (pointers, "buffer", buffer);
}
options = NULL;
if (condition)
{
options = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
if (options)
@@ -1888,7 +1899,7 @@ COMMAND_CALLBACK(eval)
expr = string_remove_quotes (ptr_args, "\"");
if (expr)
{
result = eval_expression (expr, NULL, NULL, options);
result = eval_expression (expr, pointers, NULL, options);
gui_chat_printf_date_tags (NULL, 0, "no_log", "\t>> %s", ptr_args);
if (result)
{
@@ -1911,7 +1922,7 @@ COMMAND_CALLBACK(eval)
}
else
{
result = eval_expression (ptr_args, NULL, NULL, options);
result = eval_expression (ptr_args, pointers, NULL, options);
if (result)
{
commands = string_split_command (result, ';');
@@ -1933,6 +1944,8 @@ COMMAND_CALLBACK(eval)
}
if (result)
free (result);
if (pointers)
hashtable_free (pointers);
if (options)
hashtable_free (options);
}