diff options
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua-api.c | 92 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl-api.c | 98 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python-api.c | 98 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby-api.c | 94 | ||||
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl-api.c | 84 |
5 files changed, 233 insertions, 233 deletions
diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c index 21348194f..522c4a30e 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/scripts/lua/weechat-lua-api.c @@ -1092,7 +1092,7 @@ weechat_lua_api_config_read_cb (void *data, const char *option_name, const char *value) { struct t_script_callback *script_callback; - char *lua_argv[5]; + char *lua_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -1101,8 +1101,8 @@ weechat_lua_api_config_read_cb (void *data, { lua_argv[0] = script_ptr2str (config_file); lua_argv[1] = script_ptr2str (section); - lua_argv[2] = (char *)option_name; - lua_argv[3] = (char *)value; + lua_argv[2] = (option_name) ? (char *)option_name : empty_arg; + lua_argv[3] = (value) ? (char *)value : empty_arg; lua_argv[4] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, @@ -1138,7 +1138,7 @@ weechat_lua_api_config_section_write_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *lua_argv[3]; + char *lua_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; @@ -1146,7 +1146,7 @@ weechat_lua_api_config_section_write_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { lua_argv[0] = script_ptr2str (config_file); - lua_argv[1] = (char *)section_name; + lua_argv[1] = (section_name) ? (char *)section_name : empty_arg; lua_argv[2] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, @@ -1172,7 +1172,7 @@ weechat_lua_api_config_section_write_default_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *lua_argv[3]; + char *lua_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; @@ -1180,7 +1180,7 @@ weechat_lua_api_config_section_write_default_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { lua_argv[0] = script_ptr2str (config_file); - lua_argv[1] = (char *)section_name; + lua_argv[1] = (section_name) ? (char *)section_name : empty_arg; lua_argv[2] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, @@ -1207,7 +1207,7 @@ weechat_lua_api_config_section_create_option_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *lua_argv[5]; + char *lua_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -1216,8 +1216,8 @@ weechat_lua_api_config_section_create_option_cb (void *data, { lua_argv[0] = script_ptr2str (config_file); lua_argv[1] = script_ptr2str (section); - lua_argv[2] = (char *)option_name; - lua_argv[3] = (char *)value; + lua_argv[2] = (option_name) ? (char *)option_name : empty_arg; + lua_argv[3] = (value) ? (char *)value : empty_arg; lua_argv[4] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, @@ -1412,7 +1412,7 @@ weechat_lua_api_config_option_check_value_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *lua_argv[3]; + char *lua_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -1420,7 +1420,7 @@ weechat_lua_api_config_option_check_value_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { lua_argv[0] = script_ptr2str (option); - lua_argv[1] = (char *)value; + lua_argv[1] = (value) ? (char *)value : empty_arg; lua_argv[2] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, @@ -3070,15 +3070,15 @@ weechat_lua_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, const char *command) { struct t_script_callback *script_callback; - char *lua_argv[3]; + char *lua_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { lua_argv[0] = script_ptr2str (buffer); - lua_argv[1] = (char *)command; + lua_argv[1] = (command) ? (char *)command : empty_arg; lua_argv[2] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, @@ -3163,7 +3163,7 @@ weechat_lua_api_hook_timer_cb (void *data, int remaining_calls) snprintf (str_remaining_calls, sizeof (str_remaining_calls), "%d", remaining_calls); - lua_argv[0] = NULL; + lua_argv[0] = str_remaining_calls; lua_argv[1] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, @@ -3344,7 +3344,7 @@ weechat_lua_api_hook_process_cb (void *data, { snprintf (str_rc, sizeof (str_rc), "%d", return_code); - lua_argv[0] = (char *)command; + lua_argv[0] = (command) ? (char *)command : empty_arg; lua_argv[1] = str_rc; lua_argv[2] = (stdout) ? (char *)stdout : empty_arg; lua_argv[3] = (stderr) ? (char *)stderr : empty_arg; @@ -3423,7 +3423,7 @@ int weechat_lua_api_hook_connect_cb (void *data, int status, const char *ip_address) { struct t_script_callback *script_callback; - char *lua_argv[3], str_status[32]; + char *lua_argv[3], str_status[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3433,7 +3433,7 @@ weechat_lua_api_hook_connect_cb (void *data, int status, const char *ip_address) snprintf (str_status, sizeof (str_status), "%d", status); lua_argv[0] = str_status; - lua_argv[1] = (char *)ip_address; + lua_argv[1] = (ip_address) ? (char *)ip_address : empty_arg; lua_argv[2] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, @@ -3526,7 +3526,7 @@ weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, const char *prefix, const char *message) { struct t_script_callback *script_callback; - char *lua_argv[8]; + char *lua_argv[8], empty_arg[1] = { '\0' }; static char timebuffer[64]; int *rc, ret; @@ -3546,8 +3546,8 @@ weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, lua_argv[2] = strdup (""); lua_argv[3] = (displayed) ? strdup ("1") : strdup ("0"); lua_argv[4] = (highlight) ? strdup ("1") : strdup ("0"); - lua_argv[5] = (char *)prefix; - lua_argv[6] = (char *)message; + lua_argv[5] = (prefix) ? (char *)prefix : empty_arg; + lua_argv[6] = (message) ? (char *)message : empty_arg; lua_argv[7] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, @@ -3638,19 +3638,19 @@ weechat_lua_api_hook_signal_cb (void *data, const char *signal, const char *type_data, void *signal_data) { struct t_script_callback *script_callback; - char *lua_argv[3]; - static char value_str[64], empty_value[1] = { '\0' }; + char *lua_argv[3], empty_arg[1] = { '\0' }; + static char value_str[64]; int *rc, ret, free_needed; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = (char *)signal; + lua_argv[0] = (signal) ? (char *)signal : empty_arg; free_needed = 0; if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0) { - lua_argv[1] = (signal_data) ? (char *)signal_data : empty_value; + lua_argv[1] = (signal_data) ? (char *)signal_data : empty_arg; } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0) { @@ -3664,7 +3664,7 @@ weechat_lua_api_hook_signal_cb (void *data, const char *signal, free_needed = 1; } else - lua_argv[1] = NULL; + lua_argv[1] = empty_arg; lua_argv[2] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, @@ -3795,15 +3795,15 @@ weechat_lua_api_hook_config_cb (void *data, const char *option, const char *value) { struct t_script_callback *script_callback; - char *lua_argv[3]; + char *lua_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = (char *)option; - lua_argv[1] = (char *)value; + lua_argv[0] = (option) ? (char *)option : empty_arg; + lua_argv[1] = (value) ? (char *)value : empty_arg; lua_argv[2] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, @@ -3879,14 +3879,14 @@ weechat_lua_api_hook_completion_cb (void *data, const char *completion_item, struct t_gui_completion *completion) { struct t_script_callback *script_callback; - char *lua_argv[4]; + char *lua_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = (char *)completion_item; + lua_argv[0] = (completion_item) ? (char *)completion_item : empty_arg; lua_argv[1] = script_ptr2str (buffer); lua_argv[2] = script_ptr2str (completion); lua_argv[3] = NULL; @@ -4012,15 +4012,15 @@ weechat_lua_api_hook_modifier_cb (void *data, const char *modifier, const char *string) { struct t_script_callback *script_callback; - char *lua_argv[4]; + char *lua_argv[4], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = (char *)modifier; - lua_argv[1] = (char *)modifier_data; - lua_argv[2] = (char *)string; + lua_argv[0] = (modifier) ? (char *)modifier : empty_arg; + lua_argv[1] = (modifier_data) ? (char *)modifier_data : empty_arg; + lua_argv[2] = (string) ? (char *)string : empty_arg; lua_argv[3] = NULL; return (char *)weechat_lua_exec (script_callback->script, @@ -4125,14 +4125,14 @@ weechat_lua_api_hook_info_cb (void *data, const char *info_name, const char *arguments) { struct t_script_callback *script_callback; - char *lua_argv[3]; + char *lua_argv[3], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = (char *)info_name; - lua_argv[1] = (char *)arguments; + lua_argv[0] = (info_name) ? (char *)info_name : empty_arg; + lua_argv[1] = (arguments) ? (char *)arguments : empty_arg; lua_argv[2] = NULL; return (const char *)weechat_lua_exec (script_callback->script, @@ -4198,16 +4198,16 @@ weechat_lua_api_hook_infolist_cb (void *data, const char *info_name, void *pointer, const char *arguments) { struct t_script_callback *script_callback; - char *lua_argv[4]; + char *lua_argv[4], empty_arg[1] = { '\0' }; struct t_infolist *result; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = (char *)info_name; + lua_argv[0] = (info_name) ? (char *)info_name : empty_arg; lua_argv[1] = script_ptr2str (pointer); - lua_argv[2] = (char *)arguments; + lua_argv[2] = (arguments) ? (char *)arguments : empty_arg; lua_argv[3] = NULL; result = (struct t_infolist *)weechat_lua_exec (script_callback->script, @@ -4337,15 +4337,15 @@ weechat_lua_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, const char *input_data) { struct t_script_callback *script_callback; - char *lua_argv[3]; + char *lua_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { lua_argv[0] = script_ptr2str (buffer); - lua_argv[1] = (char *)input_data; + lua_argv[1] = (input_data) ? (char *)input_data : empty_arg; lua_argv[2] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index 43e53a4ff..192e3ed2e 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -901,7 +901,7 @@ weechat_perl_api_config_section_read_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *perl_argv[5]; + char *perl_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -910,8 +910,8 @@ weechat_perl_api_config_section_read_cb (void *data, { perl_argv[0] = script_ptr2str (config_file); perl_argv[1] = script_ptr2str (section); - perl_argv[2] = (char *)option_name; - perl_argv[3] = (char *)value; + perl_argv[2] = (option_name) ? (char *)option_name : empty_arg; + perl_argv[3] = (value) ? (char *)value : empty_arg; perl_argv[4] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, @@ -947,7 +947,7 @@ weechat_perl_api_config_section_write_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *perl_argv[3]; + char *perl_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; @@ -955,7 +955,7 @@ weechat_perl_api_config_section_write_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { perl_argv[0] = script_ptr2str (config_file); - perl_argv[1] = (char *)section_name; + perl_argv[1] = (section_name) ? (char *)section_name : empty_arg; perl_argv[2] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, @@ -981,7 +981,7 @@ weechat_perl_api_config_section_write_default_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *perl_argv[3]; + char *perl_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; @@ -989,7 +989,7 @@ weechat_perl_api_config_section_write_default_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { perl_argv[0] = script_ptr2str (config_file); - perl_argv[1] = (char *)section_name; + perl_argv[1] = (section_name) ? (char *)section_name : empty_arg; perl_argv[2] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, @@ -1016,7 +1016,7 @@ weechat_perl_api_config_section_create_option_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *perl_argv[5]; + char *perl_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -1025,8 +1025,8 @@ weechat_perl_api_config_section_create_option_cb (void *data, { perl_argv[0] = script_ptr2str (config_file); perl_argv[1] = script_ptr2str (section); - perl_argv[2] = (char *)option_name; - perl_argv[3] = (char *)value; + perl_argv[2] = (option_name) ? (char *)option_name : empty_arg; + perl_argv[3] = (value) ? (char *)value : empty_arg; perl_argv[4] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, @@ -1196,7 +1196,7 @@ weechat_perl_api_config_option_check_value_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *perl_argv[3]; + char *perl_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -1204,7 +1204,7 @@ weechat_perl_api_config_option_check_value_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { perl_argv[0] = script_ptr2str (option); - perl_argv[1] = (char *)value; + perl_argv[1] = (value) ? (char *)value : empty_arg; perl_argv[2] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, @@ -2554,15 +2554,15 @@ weechat_perl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, const char *command) { struct t_script_callback *script_callback; - char *perl_argv[3]; + char *perl_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { perl_argv[0] = script_ptr2str (buffer); - perl_argv[1] = (char *)command; + perl_argv[1] = (command) ? (char *)command : empty_arg; perl_argv[2] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, @@ -2790,7 +2790,7 @@ weechat_perl_api_hook_process_cb (void *data, { snprintf (str_rc, sizeof (str_rc), "%d", return_code); - perl_argv[0] = (char *)command; + perl_argv[0] = (command) ? (char *)command : empty_arg; perl_argv[1] = str_rc; perl_argv[2] = (stdout) ? (char *)stdout : empty_arg; perl_argv[3] = (stderr) ? (char *)stderr : empty_arg; @@ -2861,7 +2861,7 @@ weechat_perl_api_hook_connect_cb (void *data, int status, const char *ip_address) { struct t_script_callback *script_callback; - char *perl_argv[3], str_status[32]; + char *perl_argv[3], str_status[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -2871,7 +2871,7 @@ weechat_perl_api_hook_connect_cb (void *data, int status, snprintf (str_status, sizeof (str_status), "%d", status); perl_argv[0] = str_status; - perl_argv[1] = (char *)ip_address; + perl_argv[1] = (ip_address) ? (char *)ip_address : empty_arg; perl_argv[2] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, @@ -2948,7 +2948,7 @@ weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, const char *prefix, const char *message) { struct t_script_callback *script_callback; - char *perl_argv[8]; + char *perl_argv[8], empty_arg[1] = { '\0' }; static char timebuffer[64]; int *rc, ret; @@ -2968,8 +2968,8 @@ weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, perl_argv[2] = strdup (""); perl_argv[3] = (displayed) ? strdup ("1") : strdup ("0"); perl_argv[4] = (highlight) ? strdup ("1") : strdup ("0"); - perl_argv[5] = (char *)prefix; - perl_argv[6] = (char *)message; + perl_argv[5] = (prefix) ? (char *)prefix : empty_arg; + perl_argv[6] = (message) ? (char *)message : empty_arg; perl_argv[7] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, @@ -3048,19 +3048,19 @@ weechat_perl_api_hook_signal_cb (void *data, const char *signal, const char *typ void *signal_data) { struct t_script_callback *script_callback; - char *perl_argv[3]; - static char value_str[64], empty_value[1] = { '\0' }; + char *perl_argv[3], empty_arg[1] = { '\0' }; + static char value_str[64]; int *rc, ret, free_needed; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = (char *)signal; + perl_argv[0] = (signal) ? (char *)signal : empty_arg; free_needed = 0; if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0) { - perl_argv[1] = (signal_data) ? (char *)signal_data : empty_value; + perl_argv[1] = (signal_data) ? (char *)signal_data : empty_arg; } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0) { @@ -3074,7 +3074,7 @@ weechat_perl_api_hook_signal_cb (void *data, const char *signal, const char *typ free_needed = 1; } else - perl_argv[1] = NULL; + perl_argv[1] = empty_arg; perl_argv[2] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, @@ -3194,15 +3194,15 @@ int weechat_perl_api_hook_config_cb (void *data, const char *option, const char *value) { struct t_script_callback *script_callback; - char *perl_argv[3]; + char *perl_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = (char *)option; - perl_argv[1] = (char *)value; + perl_argv[0] = (option) ? (char *)option : empty_arg; + perl_argv[1] = (value) ? (char *)value : empty_arg; perl_argv[2] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, @@ -3269,14 +3269,14 @@ weechat_perl_api_hook_completion_cb (void *data, const char *completion_item, struct t_gui_completion *completion) { struct t_script_callback *script_callback; - char *perl_argv[4]; + char *perl_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = (char *)completion_item; + perl_argv[0] = (completion_item) ? (char *)completion_item : empty_arg; perl_argv[1] = script_ptr2str (buffer); perl_argv[2] = script_ptr2str (completion); perl_argv[3] = NULL; @@ -3384,15 +3384,15 @@ weechat_perl_api_hook_modifier_cb (void *data, const char *modifier, const char *modifier_data, const char *string) { struct t_script_callback *script_callback; - char *perl_argv[4]; + char *perl_argv[4], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = (char *)modifier; - perl_argv[1] = (char *)modifier_data; - perl_argv[2] = (char *)string; + perl_argv[0] = (modifier) ? (char *)modifier : empty_arg; + perl_argv[1] = (modifier_data) ? (char *)modifier_data : empty_arg; + perl_argv[2] = (string) ? (char *)string : empty_arg; perl_argv[3] = NULL; return (char *)weechat_perl_exec (script_callback->script, @@ -3480,14 +3480,14 @@ weechat_perl_api_hook_info_cb (void *data, const char *info_name, const char *arguments) { struct t_script_callback *script_callback; - char *perl_argv[3]; + char *perl_argv[3], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = (char *)info_name; - perl_argv[1] = (char *)arguments; + perl_argv[0] = (info_name) ? (char *)info_name : empty_arg; + perl_argv[1] = (arguments) ? (char *)arguments : empty_arg; perl_argv[2] = NULL; return (const char *)weechat_perl_exec (script_callback->script, @@ -3545,16 +3545,16 @@ weechat_perl_api_hook_infolist_cb (void *data, const char *infolist_name, void *pointer, const char *arguments) { struct t_script_callback *script_callback; - char *perl_argv[4]; + char *perl_argv[4], empty_arg[1] = { '\0' }; struct t_infolist *result; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = (char *)infolist_name; + perl_argv[0] = (infolist_name) ? (char *)infolist_name : empty_arg; perl_argv[1] = script_ptr2str (pointer); - perl_argv[2] = (char *)arguments; + perl_argv[2] = (arguments) ? (char *)arguments : empty_arg; perl_argv[3] = NULL; result = (struct t_infolist *)weechat_perl_exec (script_callback->script, @@ -3670,15 +3670,15 @@ weechat_perl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, const char *input_data) { struct t_script_callback *script_callback; - char *perl_argv[3]; + char *perl_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { perl_argv[0] = script_ptr2str (buffer); - perl_argv[1] = (char *)input_data; + perl_argv[1] = (input_data) ? (char *)input_data : empty_arg; perl_argv[2] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index df416e0e5..6e3a7716c 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -956,7 +956,7 @@ weechat_python_api_config_read_cb (void *data, const char *option_name, const char *value) { struct t_script_callback *script_callback; - char *python_argv[5]; + char *python_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -965,8 +965,8 @@ weechat_python_api_config_read_cb (void *data, { python_argv[0] = script_ptr2str (config_file); python_argv[1] = script_ptr2str (section); - python_argv[2] = (char *)option_name; - python_argv[3] = (char *)value; + python_argv[2] = (option_name) ? (char *)option_name : empty_arg; + python_argv[3] = (value) ? (char *)value : empty_arg; python_argv[4] = NULL; rc = (int *) weechat_python_exec (script_callback->script, @@ -1002,7 +1002,7 @@ weechat_python_api_config_section_write_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *python_argv[3]; + char *python_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; @@ -1010,7 +1010,7 @@ weechat_python_api_config_section_write_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { python_argv[0] = script_ptr2str (config_file); - python_argv[1] = (char *)section_name; + python_argv[1] = (section_name) ? (char *)section_name : empty_arg; python_argv[2] = NULL; rc = (int *) weechat_python_exec (script_callback->script, @@ -1036,7 +1036,7 @@ weechat_python_api_config_section_write_default_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *python_argv[3]; + char *python_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; @@ -1044,7 +1044,7 @@ weechat_python_api_config_section_write_default_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { python_argv[0] = script_ptr2str (config_file); - python_argv[1] = (char *)section_name; + python_argv[1] = (section_name) ? (char *)section_name : empty_arg; python_argv[2] = NULL; rc = (int *) weechat_python_exec (script_callback->script, @@ -1071,7 +1071,7 @@ weechat_python_api_config_section_create_option_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *python_argv[5]; + char *python_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -1080,8 +1080,8 @@ weechat_python_api_config_section_create_option_cb (void *data, { python_argv[0] = script_ptr2str (config_file); python_argv[1] = script_ptr2str (section); - python_argv[2] = (char *)option_name; - python_argv[3] = (char *)value; + python_argv[2] = (option_name) ? (char *)option_name : empty_arg; + python_argv[3] = (value) ? (char *)value : empty_arg; python_argv[4] = NULL; rc = (int *) weechat_python_exec (script_callback->script, @@ -1263,15 +1263,15 @@ weechat_python_api_config_option_check_value_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *python_argv[3]; + char *python_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { python_argv[0] = script_ptr2str (option); - python_argv[1] = (char *)value; + python_argv[1] = (value) ? (char *)value : empty_arg; python_argv[2] = NULL; rc = (int *) weechat_python_exec (script_callback->script, @@ -2724,15 +2724,15 @@ weechat_python_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, const char *command) { struct t_script_callback *script_callback; - char *python_argv[3]; + char *python_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { python_argv[0] = script_ptr2str (buffer); - python_argv[1] = (char *)command; + python_argv[1] = (command) ? (char *)command : empty_arg; python_argv[2] = NULL; rc = (int *) weechat_python_exec (script_callback->script, @@ -2979,7 +2979,7 @@ weechat_python_api_hook_process_cb (void *data, { snprintf (str_rc, sizeof (str_rc), "%d", return_code); - python_argv[0] = (char *)command; + python_argv[0] = (command) ? (char *)command : empty_arg; python_argv[1] = str_rc; python_argv[2] = (stdout) ? (char *)stdout : empty_arg; python_argv[3] = (stderr) ? (char *)stderr : empty_arg; @@ -3053,7 +3053,7 @@ weechat_python_api_hook_connect_cb (void *data, int status, const char *ip_address) { struct t_script_callback *script_callback; - char *python_argv[3], str_status[32]; + char *python_argv[3], str_status[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3063,7 +3063,7 @@ weechat_python_api_hook_connect_cb (void *data, int status, snprintf (str_status, sizeof (str_status), "%d", status); python_argv[0] = str_status; - python_argv[1] = (char *)ip_address; + python_argv[1] = (ip_address) ? (char *)ip_address : empty_arg; python_argv[2] = NULL; rc = (int *) weechat_python_exec (script_callback->script, @@ -3147,7 +3147,7 @@ weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, const char *prefix, const char *message) { struct t_script_callback *script_callback; - char *python_argv[8]; + char *python_argv[8], empty_arg[1] = { '\0' }; static char timebuffer[64]; int *rc, ret; @@ -3167,8 +3167,8 @@ weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, python_argv[2] = strdup (""); python_argv[3] = (displayed) ? strdup ("1") : strdup ("0"); python_argv[4] = (highlight) ? strdup ("1") : strdup ("0"); - python_argv[5] = (char *)prefix; - python_argv[6] = (char *)message; + python_argv[5] = (prefix) ? (char *)prefix : empty_arg; + python_argv[6] = (message) ? (char *)message : empty_arg; python_argv[7] = NULL; rc = (int *) weechat_python_exec (script_callback->script, @@ -3252,19 +3252,19 @@ weechat_python_api_hook_signal_cb (void *data, const char *signal, const char *t void *signal_data) { struct t_script_callback *script_callback; - char *python_argv[3]; - static char value_str[64], empty_value[1] = { '\0' }; + char *python_argv[3], empty_arg[1] = { '\0' }; + static char value_str[64]; int *rc, ret, free_needed; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = (char *)signal; + python_argv[0] = (signal) ? (char *)signal : empty_arg; free_needed = 0; if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0) { - python_argv[1] = (signal_data) ? (char *)signal_data : empty_value; + python_argv[1] = (signal_data) ? (char *)signal_data : empty_arg; } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0) { @@ -3278,7 +3278,7 @@ weechat_python_api_hook_signal_cb (void *data, const char *signal, const char *t free_needed = 1; } else - python_argv[1] = NULL; + python_argv[1] = empty_arg; python_argv[2] = NULL; rc = (int *) weechat_python_exec (script_callback->script, @@ -3401,15 +3401,15 @@ int weechat_python_api_hook_config_cb (void *data, const char *option, const char *value) { struct t_script_callback *script_callback; - char *python_argv[3]; + char *python_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = (char *)option; - python_argv[1] = (char *)value; + python_argv[0] = (option) ? (char *)option : empty_arg; + python_argv[1] = (value) ? (char *)value : empty_arg; python_argv[2] = NULL; rc = (int *) weechat_python_exec (script_callback->script, @@ -3478,14 +3478,14 @@ weechat_python_api_hook_completion_cb (void *data, const char *completion_item, struct t_gui_completion *completion) { struct t_script_callback *script_callback; - char *python_argv[4]; + char *python_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = (char *)completion_item; + python_argv[0] = (completion_item) ? (char *)completion_item : empty_arg; python_argv[1] = script_ptr2str (buffer); python_argv[2] = script_ptr2str (completion); python_argv[3] = NULL; @@ -3598,15 +3598,15 @@ weechat_python_api_hook_modifier_cb (void *data, const char *modifier, const char *modifier_data, const char *string) { struct t_script_callback *script_callback; - char *python_argv[4]; + char *python_argv[4], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = (char *)modifier; - python_argv[1] = (char *)modifier_data; - python_argv[2] = (char *)string; + python_argv[0] = (modifier) ? (char *)modifier : empty_arg; + python_argv[1] = (modifier_data) ? (char *)modifier_data : empty_arg; + python_argv[2] = (string) ? (char *)string : empty_arg; python_argv[3] = NULL; return (char *)weechat_python_exec (script_callback->script, @@ -3698,14 +3698,14 @@ weechat_python_api_hook_info_cb (void *data, const char *info_name, const char *arguments) { struct t_script_callback *script_callback; - char *python_argv[3]; + char *python_argv[3], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = (char *)info_name; - python_argv[1] = (char *)arguments; + python_argv[0] = (info_name) ? (char *)info_name : empty_arg; + python_argv[1] = (arguments) ? (char *)arguments : empty_arg; python_argv[2] = NULL; return (const char *)weechat_python_exec (script_callback->script, @@ -3765,16 +3765,16 @@ weechat_python_api_hook_infolist_cb (void *data, const char *infolist_name, void *pointer, const char *arguments) { struct t_script_callback *script_callback; - char *python_argv[4]; + char *python_argv[4], empty_arg[1] = { '\0' }; struct t_infolist *result; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = (char *)infolist_name; + python_argv[0] = (infolist_name) ? (char *)infolist_name : empty_arg; python_argv[1] = script_ptr2str (pointer); - python_argv[2] = (char *)arguments; + python_argv[2] = (arguments) ? (char *)arguments : empty_arg; python_argv[3] = NULL; result = (struct t_infolist *)weechat_python_exec (script_callback->script, @@ -3894,15 +3894,15 @@ weechat_python_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer const char *input_data) { struct t_script_callback *script_callback; - char *python_argv[3]; + char *python_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { python_argv[0] = script_ptr2str (buffer); - python_argv[1] = (char *)input_data; + python_argv[1] = (input_data) ? (char *)input_data : empty_arg; python_argv[2] = NULL; rc = (int *) weechat_python_exec (script_callback->script, diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c index 9f4284d31..e3b2ff7c9 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -1089,7 +1089,7 @@ weechat_ruby_api_config_read_cb (void *data, const char *option_name, const char *value) { struct t_script_callback *script_callback; - char *ruby_argv[5]; + char *ruby_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -1098,8 +1098,8 @@ weechat_ruby_api_config_read_cb (void *data, { ruby_argv[0] = script_ptr2str (config_file); ruby_argv[1] = script_ptr2str (section); - ruby_argv[2] = (char *)option_name; - ruby_argv[3] = (char *)value; + ruby_argv[2] = (option_name) ? (char *)option_name : empty_arg; + ruby_argv[3] = (value) ? (char *)value : empty_arg; ruby_argv[4] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, @@ -1135,15 +1135,15 @@ weechat_ruby_api_config_section_write_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *ruby_argv[3]; + char *ruby_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { ruby_argv[0] = script_ptr2str (config_file); - ruby_argv[1] = (char *)section_name; + ruby_argv[1] = (section_name) ? (char *)section_name : empty_arg; ruby_argv[2] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, @@ -1169,7 +1169,7 @@ weechat_ruby_api_config_section_write_default_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *ruby_argv[3]; + char *ruby_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; @@ -1177,7 +1177,7 @@ weechat_ruby_api_config_section_write_default_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { ruby_argv[0] = script_ptr2str (config_file); - ruby_argv[1] = (char *)section_name; + ruby_argv[1] = (section_name) ? (char *)section_name : empty_arg; ruby_argv[2] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, @@ -1204,17 +1204,17 @@ weechat_ruby_api_config_section_create_option_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *ruby_argv[5]; + char *ruby_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { ruby_argv[0] = script_ptr2str (config_file); ruby_argv[1] = script_ptr2str (section); - ruby_argv[2] = (char *)option_name; - ruby_argv[3] = (char *)value; + ruby_argv[2] = (option_name) ? (char *)option_name : empty_arg; + ruby_argv[3] = (value) ? (char *)value : empty_arg; ruby_argv[4] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, @@ -1429,15 +1429,15 @@ weechat_ruby_api_config_option_check_value_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *ruby_argv[3]; + char *ruby_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { ruby_argv[0] = script_ptr2str (option); - ruby_argv[1] = (char *)value; + ruby_argv[1] = (value) ? (char *)value : empty_arg; ruby_argv[2] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, @@ -3122,7 +3122,7 @@ weechat_ruby_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, const char *command) { struct t_script_callback *script_callback; - char *ruby_argv[3]; + char *ruby_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3130,7 +3130,7 @@ weechat_ruby_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { ruby_argv[0] = script_ptr2str (buffer); - ruby_argv[1] = (char *)command; + ruby_argv[1] = (command) ? (char *)command : empty_arg; ruby_argv[2] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, @@ -3407,7 +3407,7 @@ weechat_ruby_api_hook_process_cb (void *data, { snprintf (str_rc, sizeof (str_rc), "%d", return_code); - ruby_argv[0] = (char *)command; + ruby_argv[0] = (command) ? (char *)command : empty_arg; ruby_argv[1] = str_rc; ruby_argv[2] = (stdout) ? (char *)stdout : empty_arg; ruby_argv[3] = (stderr) ? (char *)stderr : empty_arg; @@ -3490,7 +3490,7 @@ weechat_ruby_api_hook_connect_cb (void *data, int status, const char *ip_address) { struct t_script_callback *script_callback; - char *ruby_argv[3], str_status[32]; + char *ruby_argv[3], str_status[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3500,7 +3500,7 @@ weechat_ruby_api_hook_connect_cb (void *data, int status, snprintf (str_status, sizeof (str_status), "%d", status); ruby_argv[0] = str_status; - ruby_argv[1] = (char *)ip_address; + ruby_argv[1] = (ip_address) ? (char *)ip_address : empty_arg; ruby_argv[2] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, @@ -3602,7 +3602,7 @@ weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, const char *prefix, const char *message) { struct t_script_callback *script_callback; - char *ruby_argv[8]; + char *ruby_argv[8], empty_arg[1] = { '\0' }; static char timebuffer[64]; int *rc, ret; @@ -3622,8 +3622,8 @@ weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, ruby_argv[2] = strdup (""); ruby_argv[3] = (displayed) ? strdup ("1") : strdup ("0"); ruby_argv[4] = (highlight) ? strdup ("1") : strdup ("0"); - ruby_argv[5] = (char *)prefix; - ruby_argv[6] = (char *)message; + ruby_argv[5] = (prefix) ? (char *)prefix : empty_arg; + ruby_argv[6] = (message) ? (char *)message : empty_arg; ruby_argv[7] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, @@ -3720,19 +3720,19 @@ weechat_ruby_api_hook_signal_cb (void *data, const char *signal, const char *typ void *signal_data) { struct t_script_callback *script_callback; - char *ruby_argv[3]; - static char value_str[64], empty_value[1] = { '\0' }; + char *ruby_argv[3], empty_arg[1] = { '\0' }; + static char value_str[64]; int *rc, ret, free_needed; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { ruby_argv[0] = (char *)signal; free_needed = 0; if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0) { - ruby_argv[1] = (signal_data) ? (char *)signal_data : empty_value; + ruby_argv[1] = (signal_data) ? (char *)signal_data : empty_arg; } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0) { @@ -3746,7 +3746,7 @@ weechat_ruby_api_hook_signal_cb (void *data, const char *signal, const char *typ free_needed = 1; } else - ruby_argv[1] = NULL; + ruby_argv[1] = empty_arg; ruby_argv[2] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, @@ -3883,15 +3883,15 @@ int weechat_ruby_api_hook_config_cb (void *data, const char *option, const char *value) { struct t_script_callback *script_callback; - char *ruby_argv[3]; + char *ruby_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = (char *)option; - ruby_argv[1] = (char *)value; + ruby_argv[0] = (option) ? (char *)option : empty_arg; + ruby_argv[1] = (value) ? (char *)value : empty_arg; ruby_argv[2] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, @@ -3966,14 +3966,14 @@ weechat_ruby_api_hook_completion_cb (void *data, const char *completion_item, struct t_gui_completion *completion) { struct t_script_callback *script_callback; - char *ruby_argv[4]; + char *ruby_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = (char *)completion_item; + ruby_argv[0] = (completion_item) ? (char *)completion_item : empty_arg; ruby_argv[1] = script_ptr2str (buffer); ruby_argv[2] = script_ptr2str (completion); ruby_argv[3] = NULL; @@ -4105,15 +4105,15 @@ weechat_ruby_api_hook_modifier_cb (void *data, const char *modifier, const char *modifier_data, const char *string) { struct t_script_callback *script_callback; - char *ruby_argv[4]; + char *ruby_argv[4], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = (char *)modifier; - ruby_argv[1] = (char *)modifier_data; - ruby_argv[2] = (char *)string; + ruby_argv[0] = (modifier) ? (char *)modifier : empty_arg; + ruby_argv[1] = (modifier_data) ? (char *)modifier_data : empty_arg; + ruby_argv[2] = (string) ? (char *)string : empty_arg; ruby_argv[3] = NULL; return (char *)weechat_ruby_exec (script_callback->script, @@ -4220,14 +4220,14 @@ weechat_ruby_api_hook_info_cb (void *data, const char *info_name, const char *arguments) { struct t_script_callback *script_callback; - char *ruby_argv[3]; + char *ruby_argv[3], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = (char *)info_name; - ruby_argv[1] = (char *)arguments; + ruby_argv[0] = (info_name) ? (char *)info_name : empty_arg; + ruby_argv[1] = (arguments) ? (char *)arguments : empty_arg; ruby_argv[2] = NULL; return (const char *)weechat_ruby_exec (script_callback->script, @@ -4296,16 +4296,16 @@ weechat_ruby_api_hook_infolist_cb (void *data, const char *infolist_name, void *pointer, const char *arguments) { struct t_script_callback *script_callback; - char *ruby_argv[4]; + char *ruby_argv[4], empty_arg[1] = { '\0' }; struct t_infolist *result; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = (char *)infolist_name; + ruby_argv[0] = (infolist_name) ? (char *)infolist_name : empty_arg; ruby_argv[1] = script_ptr2str (pointer); - ruby_argv[2] = (char *)arguments; + ruby_argv[2] = (arguments) ? (char *)arguments : empty_arg; ruby_argv[3] = NULL; result = (struct t_infolist *)weechat_ruby_exec (script_callback->script, @@ -4437,15 +4437,15 @@ weechat_ruby_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, const char *input_data) { struct t_script_callback *script_callback; - char *ruby_argv[3]; + char *ruby_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { ruby_argv[0] = script_ptr2str (buffer); - ruby_argv[1] = (char *)input_data; + ruby_argv[1] = (input_data) ? (char *)input_data : empty_arg; ruby_argv[2] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c index 09cd94ea0..59927ec36 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/scripts/tcl/weechat-tcl-api.c @@ -1104,7 +1104,7 @@ weechat_tcl_api_config_section_read_cb (void *data, const char *option_name, const char *value) { struct t_script_callback *script_callback; - char *tcl_argv[5]; + char *tcl_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -1113,8 +1113,8 @@ weechat_tcl_api_config_section_read_cb (void *data, { tcl_argv[0] = script_ptr2str (config_file); tcl_argv[1] = script_ptr2str (section); - tcl_argv[2] = (char *)option_name; - tcl_argv[3] = (char *)value; + tcl_argv[2] = (option_name) ? (char *)option_name : empty_arg; + tcl_argv[3] = (value) ? (char *)value : empty_arg; tcl_argv[4] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, @@ -1150,7 +1150,7 @@ weechat_tcl_api_config_section_write_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *tcl_argv[3]; + char *tcl_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; @@ -1158,7 +1158,7 @@ weechat_tcl_api_config_section_write_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { tcl_argv[0] = script_ptr2str (config_file); - tcl_argv[1] = (char *)section_name; + tcl_argv[1] = (section_name) ? (char *)section_name : empty_arg; tcl_argv[2] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, @@ -1184,7 +1184,7 @@ weechat_tcl_api_config_section_write_default_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *tcl_argv[3]; + char *tcl_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; @@ -1192,7 +1192,7 @@ weechat_tcl_api_config_section_write_default_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { tcl_argv[0] = script_ptr2str (config_file); - tcl_argv[1] = (char *)section_name; + tcl_argv[1] = (section_name) ? (char *)section_name : empty_arg; tcl_argv[2] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, @@ -1220,7 +1220,7 @@ weechat_tcl_api_config_section_create_option_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *tcl_argv[5]; + char *tcl_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -1229,8 +1229,8 @@ weechat_tcl_api_config_section_create_option_cb (void *data, { tcl_argv[0] = script_ptr2str (config_file); tcl_argv[1] = script_ptr2str (section); - tcl_argv[2] = (char *)option_name; - tcl_argv[3] = (char *)value; + tcl_argv[2] = (option_name) ? (char *)option_name : empty_arg; + tcl_argv[3] = (value) ? (char *)value : empty_arg; tcl_argv[4] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, @@ -1416,7 +1416,7 @@ weechat_tcl_api_config_option_check_value_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *tcl_argv[3]; + char *tcl_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -1424,7 +1424,7 @@ weechat_tcl_api_config_option_check_value_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { tcl_argv[0] = script_ptr2str (option); - tcl_argv[1] = (char *)value; + tcl_argv[1] = (value) ? (char *)value : empty_arg; tcl_argv[2] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, @@ -2929,7 +2929,7 @@ weechat_tcl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, const char *command) { struct t_script_callback *script_callback; - char *tcl_argv[3]; + char *tcl_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -2937,7 +2937,7 @@ weechat_tcl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { tcl_argv[0] = script_ptr2str (buffer); - tcl_argv[1] = (char *)command; + tcl_argv[1] = (command) ? (char *)command : empty_arg; tcl_argv[2] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, @@ -3193,7 +3193,7 @@ weechat_tcl_api_hook_process_cb (void *data, { snprintf (str_rc, sizeof (str_rc), "%d", return_code); - tcl_argv[0] = (char *)command; + tcl_argv[0] = (command) ? (char *)command : empty_arg; tcl_argv[1] = str_rc; tcl_argv[2] = (stdout) ? (char *)stdout : empty_arg; tcl_argv[3] = (stderr) ? (char *)stderr : empty_arg; @@ -3273,7 +3273,7 @@ weechat_tcl_api_hook_connect_cb (void *data, int status, const char *ip_address) { struct t_script_callback *script_callback; - char *tcl_argv[3], str_status[32]; + char *tcl_argv[3], str_status[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3283,7 +3283,7 @@ weechat_tcl_api_hook_connect_cb (void *data, int status, snprintf (str_status, sizeof (str_status), "%d", status); tcl_argv[0] = str_status; - tcl_argv[1] = (char *)ip_address; + tcl_argv[1] = (ip_address) ? (char *)ip_address : empty_arg; tcl_argv[2] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, @@ -3372,7 +3372,7 @@ weechat_tcl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, const char *prefix, const char *message) { struct t_script_callback *script_callback; - char *tcl_argv[8]; + char *tcl_argv[8], empty_arg[1] = { '\0' }; static char timebuffer[64]; int *rc, ret; @@ -3392,8 +3392,8 @@ weechat_tcl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, tcl_argv[2] = strdup (""); tcl_argv[3] = (displayed) ? strdup ("1") : strdup ("0"); tcl_argv[4] = (highlight) ? strdup ("1") : strdup ("0"); - tcl_argv[5] = (char *)prefix; - tcl_argv[6] = (char *)message; + tcl_argv[5] = (prefix) ? (char *)prefix : empty_arg; + tcl_argv[6] = (message) ? (char *)message : empty_arg; tcl_argv[7] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, @@ -3481,8 +3481,8 @@ weechat_tcl_api_hook_signal_cb (void *data, const char *signal, const char *type void *signal_data) { struct t_script_callback *script_callback; - char *tcl_argv[3]; - static char value_str[64], empty_value[1] = { '\0' }; + char *tcl_argv[3], empty_arg[1] = { '\0' }; + static char value_str[64]; int *rc, ret, free_needed; script_callback = (struct t_script_callback *)data; @@ -3493,7 +3493,7 @@ weechat_tcl_api_hook_signal_cb (void *data, const char *signal, const char *type free_needed = 0; if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0) { - tcl_argv[1] = (signal_data) ? (char *)signal_data : empty_value; + tcl_argv[1] = (signal_data) ? (char *)signal_data : empty_arg; } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0) { @@ -3507,7 +3507,7 @@ weechat_tcl_api_hook_signal_cb (void *data, const char *signal, const char *type free_needed = 1; } else - tcl_argv[1] = NULL; + tcl_argv[1] = empty_arg; tcl_argv[2] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, @@ -3636,15 +3636,15 @@ int weechat_tcl_api_hook_config_cb (void *data, const char *option, const char *value) { struct t_script_callback *script_callback; - char *tcl_argv[3]; + char *tcl_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = (char *)option; - tcl_argv[1] = (char *)value; + tcl_argv[0] = (option) ? (char *)option : empty_arg; + tcl_argv[1] = (value) ? (char *)value : empty_arg; tcl_argv[2] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, @@ -3714,14 +3714,14 @@ weechat_tcl_api_hook_completion_cb (void *data, const char *completion_item, struct t_gui_completion *completion) { struct t_script_callback *script_callback; - char *tcl_argv[4]; + char *tcl_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = (char *)completion_item; + tcl_argv[0] = (completion_item) ? (char *)completion_item : empty_arg; tcl_argv[1] = script_ptr2str (buffer); tcl_argv[2] = script_ptr2str (completion); tcl_argv[3] = NULL; @@ -3841,15 +3841,15 @@ weechat_tcl_api_hook_modifier_cb (void *data, const char *modifier, const char *modifier_data, const char *string) { struct t_script_callback *script_callback; - char *tcl_argv[4]; + char *tcl_argv[4], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = (char *)modifier; - tcl_argv[1] = (char *)modifier_data; - tcl_argv[2] = (char *)string; + tcl_argv[0] = (modifier) ? (char *)modifier : empty_arg; + tcl_argv[1] = (modifier_data) ? (char *)modifier_data : empty_arg; + tcl_argv[2] = (string) ? (char *)string : empty_arg; tcl_argv[3] = NULL; return (char *)weechat_tcl_exec (script_callback->script, @@ -3943,14 +3943,14 @@ weechat_tcl_api_hook_info_cb (void *data, const char *info_name, const char *arguments) { struct t_script_callback *script_callback; - char *tcl_argv[3]; + char *tcl_argv[3], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = (char *)info_name; - tcl_argv[1] = (char *)arguments; + tcl_argv[0] = (info_name) ? (char *)info_name : empty_arg; + tcl_argv[1] = (arguments) ? (char *)arguments : empty_arg; tcl_argv[2] = NULL; return (const char *)weechat_tcl_exec (script_callback->script, @@ -4011,16 +4011,16 @@ weechat_tcl_api_hook_infolist_cb (void *data, const char *infolist_name, void *pointer, const char *arguments) { struct t_script_callback *script_callback; - char *tcl_argv[4]; + char *tcl_argv[4], empty_arg[1] = { '\0' }; struct t_infolist *result; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = (char *)infolist_name; + tcl_argv[0] = (infolist_name) ? (char *)infolist_name : empty_arg; tcl_argv[1] = script_ptr2str (pointer); - tcl_argv[2] = (char *)arguments; + tcl_argv[2] = (arguments) ? (char *)arguments : empty_arg; tcl_argv[3] = NULL; result = (struct t_infolist *)weechat_tcl_exec (script_callback->script, @@ -4145,7 +4145,7 @@ weechat_tcl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, const char *input_data) { struct t_script_callback *script_callback; - char *tcl_argv[3]; + char *tcl_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -4153,7 +4153,7 @@ weechat_tcl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { tcl_argv[0] = script_ptr2str (buffer); - tcl_argv[1] = (char *)input_data; + tcl_argv[1] = (input_data) ? (char *)input_data : empty_arg; tcl_argv[2] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, |