summaryrefslogtreecommitdiff
path: root/src/core/wee-command.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2014-08-29 19:11:07 +0200
committerSébastien Helleu <flashcode@flashtux.org>2014-08-29 19:11:07 +0200
commit421c0752d8fe3cf37d8c4b3ff13d4fe3dcb69034 (patch)
tree306d8f78435f86a857e93d9b262611510ab81642 /src/core/wee-command.c
parentdda2170d940645c223114b903afa6ef94ab9594d (diff)
downloadweechat-421c0752d8fe3cf37d8c4b3ff13d4fe3dcb69034.zip
core: fix window/buffer pointers used in command /eval
Diffstat (limited to 'src/core/wee-command.c')
-rw-r--r--src/core/wee-command.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 5f22d82c4..2d20ba499 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -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);
}