1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-09 03:03:12 +02:00

trigger: execute trigger command on appropriate buffer (issue #1841)

This affects the following hook types:

- command
- command_run
- line
- modifier
- print

This fixes a regression introduced in WeeChat 3.7 by commit
0f67f55098.
This commit is contained in:
Sébastien Helleu
2022-10-20 20:39:39 +02:00
parent a0bba1325a
commit dc034e2685
2 changed files with 22 additions and 11 deletions
+7
View File
@@ -15,6 +15,13 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
(file _ReleaseNotes.adoc_ in sources). (file _ReleaseNotes.adoc_ in sources).
[[v3.7.1]]
== Version 3.7.1 (under dev)
Bug fixes::
* trigger: execute trigger command on appropriate buffer for hooks command, command_run, line, modifier and print (issue #1841)
[[v3.7]] [[v3.7]]
== Version 3.7 (2022-10-09) == Version 3.7 (2022-10-09)
+15 -11
View File
@@ -720,7 +720,6 @@ trigger_callback_modifier_cb (const void *pointer, void *data,
const char *modifier, const char *modifier_data, const char *modifier, const char *modifier_data,
const char *string) const char *string)
{ {
struct t_gui_buffer *buffer;
const char *ptr_string; const char *ptr_string;
char *string_modified, *pos, *buffer_pointer; char *string_modified, *pos, *buffer_pointer;
char *str_tags, **tags, *prefix, *string_no_color; char *str_tags, **tags, *prefix, *string_no_color;
@@ -730,7 +729,7 @@ trigger_callback_modifier_cb (const void *pointer, void *data,
TRIGGER_CALLBACK_CB_INIT(NULL); TRIGGER_CALLBACK_CB_INIT(NULL);
buffer = NULL; ctx.buffer = NULL;
tags = NULL; tags = NULL;
num_tags = 0; num_tags = 0;
string_no_color = NULL; string_no_color = NULL;
@@ -842,15 +841,15 @@ trigger_callback_modifier_cb (const void *pointer, void *data,
rc = sscanf (buffer_pointer, "0x%lx", &value); rc = sscanf (buffer_pointer, "0x%lx", &value);
if ((rc != EOF) && (rc != 0)) if ((rc != EOF) && (rc != 0))
{ {
buffer = (struct t_gui_buffer *)value; ctx.buffer = (struct t_gui_buffer *)value;
weechat_hashtable_set ( weechat_hashtable_set (
ctx.extra_vars, ctx.extra_vars,
"tg_plugin", "tg_plugin",
weechat_buffer_get_string (buffer, "plugin")); weechat_buffer_get_string (ctx.buffer, "plugin"));
weechat_hashtable_set ( weechat_hashtable_set (
ctx.extra_vars, ctx.extra_vars,
"tg_buffer", "tg_buffer",
weechat_buffer_get_string (buffer, "full_name")); weechat_buffer_get_string (ctx.buffer, "full_name"));
pos++; pos++;
if (pos[0]) if (pos[0])
{ {
@@ -877,12 +876,12 @@ trigger_callback_modifier_cb (const void *pointer, void *data,
free (buffer_pointer); free (buffer_pointer);
} }
} }
weechat_hashtable_set (ctx.pointers, "buffer", buffer); weechat_hashtable_set (ctx.pointers, "buffer", ctx.buffer);
} }
if (tags) if (tags)
{ {
if (!trigger_callback_set_tags (buffer, (const char **)tags, num_tags, if (!trigger_callback_set_tags (ctx.buffer, (const char **)tags, num_tags,
ctx.extra_vars)) ctx.extra_vars))
{ {
goto end; goto end;
@@ -914,7 +913,6 @@ trigger_callback_line_cb (const void *pointer, void *data,
struct t_hashtable *line) struct t_hashtable *line)
{ {
struct t_hashtable *hashtable; struct t_hashtable *hashtable;
struct t_gui_buffer *buffer;
struct t_weelist_item *ptr_item; struct t_weelist_item *ptr_item;
unsigned long value; unsigned long value;
const char *ptr_key, *ptr_value; const char *ptr_key, *ptr_value;
@@ -943,9 +941,9 @@ trigger_callback_line_cb (const void *pointer, void *data,
rc = sscanf (ptr_value + 2, "%lx", &value); rc = sscanf (ptr_value + 2, "%lx", &value);
if ((rc == EOF) || (rc < 1)) if ((rc == EOF) || (rc < 1))
goto end; goto end;
buffer = (void *)value; ctx.buffer = (void *)value;
weechat_hashtable_set (ctx.pointers, "buffer", buffer); weechat_hashtable_set (ctx.pointers, "buffer", ctx.buffer);
ptr_value = weechat_hashtable_get (line, "tags"); ptr_value = weechat_hashtable_get (line, "tags");
tags = weechat_string_split ((ptr_value) ? ptr_value : "", tags = weechat_string_split ((ptr_value) ? ptr_value : "",
",", ",",
@@ -981,7 +979,7 @@ trigger_callback_line_cb (const void *pointer, void *data,
if (string_no_color) if (string_no_color)
free (string_no_color); free (string_no_color);
if (!trigger_callback_set_tags (buffer, (const char **)tags, num_tags, if (!trigger_callback_set_tags (ctx.buffer, (const char **)tags, num_tags,
ctx.extra_vars)) ctx.extra_vars))
{ {
goto end; goto end;
@@ -1063,6 +1061,8 @@ trigger_callback_print_cb (const void *pointer, void *data,
TRIGGER_CALLBACK_CB_INIT(WEECHAT_RC_OK); TRIGGER_CALLBACK_CB_INIT(WEECHAT_RC_OK);
ctx.buffer = buffer;
/* do nothing if the buffer does not match buffers defined in the trigger */ /* do nothing if the buffer does not match buffers defined in the trigger */
if (trigger->hook_print_buffers if (trigger->hook_print_buffers
&& !weechat_buffer_match_list (buffer, trigger->hook_print_buffers)) && !weechat_buffer_match_list (buffer, trigger->hook_print_buffers))
@@ -1143,6 +1143,8 @@ trigger_callback_command_cb (const void *pointer, void *data,
TRIGGER_CALLBACK_CB_NEW_POINTERS; TRIGGER_CALLBACK_CB_NEW_POINTERS;
TRIGGER_CALLBACK_CB_NEW_EXTRA_VARS; TRIGGER_CALLBACK_CB_NEW_EXTRA_VARS;
ctx.buffer = buffer;
/* add data in hashtables used for conditions/replace/command */ /* add data in hashtables used for conditions/replace/command */
trigger_callback_set_common_vars (trigger, ctx.extra_vars); trigger_callback_set_common_vars (trigger, ctx.extra_vars);
weechat_hashtable_set (ctx.pointers, "buffer", buffer); weechat_hashtable_set (ctx.pointers, "buffer", buffer);
@@ -1194,6 +1196,8 @@ trigger_callback_command_run_cb (const void *pointer, void *data,
TRIGGER_CALLBACK_CB_NEW_POINTERS; TRIGGER_CALLBACK_CB_NEW_POINTERS;
TRIGGER_CALLBACK_CB_NEW_EXTRA_VARS; TRIGGER_CALLBACK_CB_NEW_EXTRA_VARS;
ctx.buffer = buffer;
/* add data in hashtables used for conditions/replace/command */ /* add data in hashtables used for conditions/replace/command */
trigger_callback_set_common_vars (trigger, ctx.extra_vars); trigger_callback_set_common_vars (trigger, ctx.extra_vars);
weechat_hashtable_set (ctx.pointers, "buffer", buffer); weechat_hashtable_set (ctx.pointers, "buffer", buffer);