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

exec: fix use of same task id for different tasks (closes #1491)

This commit is contained in:
Sébastien Helleu
2020-05-03 16:07:11 +02:00
parent df26301d03
commit 5438f62f74
18 changed files with 100 additions and 110 deletions
+3 -3
View File
@@ -87,7 +87,7 @@ exec_command_list ()
/* running command */
weechat_printf (NULL,
/* TRANSLATORS: %s before "ago" is elapsed time, for example: "3m59" */
_(" %s%s%s %d%s%s%s: %s\"%s%s%s\"%s (pid: %d, "
_(" %s%s%s %ld%s%s%s: %s\"%s%s%s\"%s (pid: %d, "
"started %s ago)"),
weechat_color (weechat_config_string (exec_config_color_flag_running)),
">>",
@@ -116,7 +116,7 @@ exec_command_list ()
"%Y-%m-%d %H:%M:%S", local_time) == 0)
str_time2[0] = '\0';
weechat_printf (NULL,
" %s%s%s %d%s%s%s: %s\"%s%s%s\"%s (%s -> %s, %s)",
" %s%s%s %ld%s%s%s: %s\"%s%s%s\"%s (%s -> %s, %s)",
weechat_color (weechat_config_string (exec_config_color_flag_finished)),
"[]",
weechat_color ("reset"),
@@ -553,7 +553,7 @@ exec_command_run (struct t_gui_buffer *buffer,
else
{
snprintf (str_buffer, sizeof (str_buffer),
"exec.%d", new_exec_cmd->number);
"exec.%ld", new_exec_cmd->number);
}
ptr_new_buffer = exec_buffer_new (str_buffer,
(cmd_options.new_buffer == 2),
+2 -1
View File
@@ -49,7 +49,8 @@ exec_completion_commands_ids_cb (const void *pointer, void *data,
for (ptr_exec_cmd = exec_cmds; ptr_exec_cmd;
ptr_exec_cmd = ptr_exec_cmd->next_cmd)
{
snprintf (str_number, sizeof (str_number), "%d", ptr_exec_cmd->number);
snprintf (str_number, sizeof (str_number),
"%ld", ptr_exec_cmd->number);
weechat_hook_completion_list_add (completion, str_number,
0, WEECHAT_LIST_POS_SORT);
if (ptr_exec_cmd->name)
+22 -34
View File
@@ -95,7 +95,7 @@ exec_search_by_id (const char *id)
ptr_exec_cmd = ptr_exec_cmd->next_cmd)
{
/* check if number is matching */
if ((number >= 0) && (ptr_exec_cmd->number == (int)number))
if ((number >= 0) && (ptr_exec_cmd->number == number))
return ptr_exec_cmd;
/* check if name is matching */
@@ -114,36 +114,14 @@ exec_search_by_id (const char *id)
struct t_exec_cmd *
exec_add ()
{
struct t_exec_cmd *new_exec_cmd, *ptr_exec_cmd;
int i, number;
/* find first available number */
number = (last_exec_cmd) ? last_exec_cmd->number + 1 : 0;
for (ptr_exec_cmd = exec_cmds; ptr_exec_cmd;
ptr_exec_cmd = ptr_exec_cmd->next_cmd)
{
if (ptr_exec_cmd->prev_cmd
&& (ptr_exec_cmd->number > ptr_exec_cmd->prev_cmd->number + 1))
{
number = ptr_exec_cmd->prev_cmd->number + 1;
break;
}
}
struct t_exec_cmd *new_exec_cmd;
int i;
new_exec_cmd = malloc (sizeof (*new_exec_cmd));
if (!new_exec_cmd)
return NULL;
new_exec_cmd->prev_cmd = last_exec_cmd;
new_exec_cmd->next_cmd = NULL;
if (last_exec_cmd)
last_exec_cmd->next_cmd = new_exec_cmd;
else
exec_cmds = new_exec_cmd;
last_exec_cmd = new_exec_cmd;
new_exec_cmd->number = number;
new_exec_cmd->number = (last_exec_cmd) ? last_exec_cmd->number + 1 : 0;
new_exec_cmd->name = NULL;
new_exec_cmd->hook = NULL;
new_exec_cmd->command = NULL;
@@ -166,6 +144,15 @@ exec_add ()
new_exec_cmd->pipe_command = NULL;
new_exec_cmd->hsignal = NULL;
/* add exec to list */
new_exec_cmd->prev_cmd = last_exec_cmd;
new_exec_cmd->next_cmd = NULL;
if (last_exec_cmd)
last_exec_cmd->next_cmd = new_exec_cmd;
else
exec_cmds = new_exec_cmd;
last_exec_cmd = new_exec_cmd;
exec_cmds_count++;
return new_exec_cmd;
@@ -343,7 +330,7 @@ exec_display_line (struct t_exec_cmd *exec_cmd, struct t_gui_buffer *buffer,
}
else
{
snprintf (str_number, sizeof (str_number), "%d", exec_cmd->number);
snprintf (str_number, sizeof (str_number), "%ld", exec_cmd->number);
snprintf (str_tags, sizeof (str_tags),
"exec_%s,exec_cmd_%s",
(out == EXEC_STDOUT) ? "stdout" : "stderr",
@@ -460,7 +447,8 @@ exec_end_command (struct t_exec_cmd *exec_cmd, int return_code)
if (hashtable)
{
weechat_hashtable_set (hashtable, "command", exec_cmd->command);
snprintf (str_number, sizeof (str_number), "%d", exec_cmd->number);
snprintf (str_number, sizeof (str_number),
"%ld", exec_cmd->number);
weechat_hashtable_set (hashtable, "number", str_number);
weechat_hashtable_set (hashtable, "name", exec_cmd->name);
output = exec_decode_color (exec_cmd, exec_cmd->output[EXEC_STDOUT]);
@@ -501,8 +489,8 @@ exec_end_command (struct t_exec_cmd *exec_cmd, int return_code)
if (buffer_type == 1)
{
weechat_printf_y (ptr_buffer, -1,
("%s: end of command %d (\"%s\"), "
"return code: %d"),
_("%s: end of command %ld (\"%s\"), "
"return code: %d"),
EXEC_PLUGIN_NAME, exec_cmd->number,
exec_cmd->command, return_code);
}
@@ -510,7 +498,7 @@ exec_end_command (struct t_exec_cmd *exec_cmd, int return_code)
{
weechat_printf_date_tags (
ptr_buffer, 0, "exec_rc",
_("%s: end of command %d (\"%s\"), "
_("%s: end of command %ld (\"%s\"), "
"return code: %d"),
EXEC_PLUGIN_NAME, exec_cmd->number,
exec_cmd->command, return_code);
@@ -521,7 +509,7 @@ exec_end_command (struct t_exec_cmd *exec_cmd, int return_code)
if (buffer_type == 1)
{
weechat_printf_y (ptr_buffer, -1,
_("%s: unexpected end of command %d "
_("%s: unexpected end of command %ld "
"(\"%s\")"),
EXEC_PLUGIN_NAME, exec_cmd->number,
exec_cmd->command);
@@ -530,7 +518,7 @@ exec_end_command (struct t_exec_cmd *exec_cmd, int return_code)
{
weechat_printf_date_tags (
ptr_buffer, 0, "exec_rc",
_("%s: unexpected end of command %d "
_("%s: unexpected end of command %ld "
"(\"%s\")"),
EXEC_PLUGIN_NAME, exec_cmd->number,
exec_cmd->command);
@@ -685,7 +673,7 @@ exec_print_log ()
{
weechat_log_printf ("");
weechat_log_printf ("[exec command (addr:0x%lx)]", ptr_exec_cmd);
weechat_log_printf (" number. . . . . . . . . . : %d", ptr_exec_cmd->number);
weechat_log_printf (" number. . . . . . . . . . : %ld", ptr_exec_cmd->number);
weechat_log_printf (" name. . . . . . . . . . . : '%s'", ptr_exec_cmd->name);
weechat_log_printf (" hook. . . . . . . . . . . : 0x%lx", ptr_exec_cmd->hook);
weechat_log_printf (" command . . . . . . . . . : '%s'", ptr_exec_cmd->command);
+1 -1
View File
@@ -43,7 +43,7 @@ enum t_exec_color
struct t_exec_cmd
{
/* command/process */
int number; /* command number */
long number; /* command number */
char *name; /* name of command */
struct t_hook *hook; /* pointer to process hook */
char *command; /* command (with arguments) */