1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

scripts: fix issue with long interval in function hook_timer

Affected plugins: python, ruby, lua, tcl, guile, javascript, php.
This commit is contained in:
Sébastien Helleu
2022-08-01 22:18:38 +02:00
parent b1404b0277
commit bcb8647aa4
11 changed files with 35 additions and 14 deletions
+1
View File
@@ -33,6 +33,7 @@ Bug fixes::
* javascript: fix return of long value in functions infolist_time, hdata_long and hdata_time
* relay: fix parsing of IRC messages received from clients (issue #1796)
* scripts: fix issue with year ≥ 2038 in functions infolist_new_var_time, print_date_tags and print_y_date_tags (plugins: python/lua/tcl/guile/javascript)
* scripts: fix issue with long interval in function hook_timer (plugins: python/ruby/lua/tcl/guile/javascript/php)
* xfer: fix crash when closing DCC chat buffer
Tests::
+1 -1
View File
@@ -2255,7 +2255,7 @@ weechat_guile_api_hook_timer (SCM interval, SCM align_second, SCM max_calls,
result = API_PTR2STR(plugin_script_api_hook_timer (weechat_guile_plugin,
guile_current_script,
scm_to_int (interval),
scm_to_long (interval),
scm_to_int (align_second),
scm_to_int (max_calls),
&weechat_guile_api_hook_timer_cb,
+3 -2
View File
@@ -2148,10 +2148,11 @@ weechat_js_api_hook_timer_cb (const void *pointer, void *data,
API_FUNC(hook_timer)
{
int interval, align_second, max_calls;
long interval;
int align_second, max_calls;
const char *result;
API_INIT_FUNC(1, "hook_timer", "iiiss", API_RETURN_EMPTY);
API_INIT_FUNC(1, "hook_timer", "niiss", API_RETURN_EMPTY);
interval = args[0]->IntegerValue();
align_second = args[1]->IntegerValue();
+2 -1
View File
@@ -2361,7 +2361,8 @@ weechat_lua_api_hook_timer_cb (const void *pointer, void *data,
API_FUNC(hook_timer)
{
int interval, align_second, max_calls;
long interval;
int align_second, max_calls;
const char *function, *data;
const char *result;
+3 -2
View File
@@ -2376,7 +2376,8 @@ API_FUNC(hook_timer)
zend_long z_interval, z_align_second, z_max_calls;
zval *z_callback;
zend_string *z_data;
int interval, align_second, max_calls;
long interval;
int align_second, max_calls;
char *data;
const char *result;
@@ -2386,7 +2387,7 @@ API_FUNC(hook_timer)
&z_data) == FAILURE)
API_WRONG_ARGS(API_RETURN_EMPTY);
interval = (int)z_interval;
interval = (long)z_interval;
align_second = (int)z_align_second;
max_calls = (int)z_max_calls;
weechat_php_get_function_name (z_callback, callback_name);
+1 -1
View File
@@ -523,7 +523,7 @@ plugin_script_api_hook_command_run (struct t_weechat_plugin *weechat_plugin,
struct t_hook *
plugin_script_api_hook_timer (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
int interval, int align_second, int max_calls,
long interval, int align_second, int max_calls,
int (*callback)(const void *pointer,
void *data,
int remaining_calls),
+1 -1
View File
@@ -151,7 +151,7 @@ extern struct t_hook *plugin_script_api_hook_command_run (struct t_weechat_plugi
const char *data);
extern struct t_hook *plugin_script_api_hook_timer (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
int interval, int align_second,
long interval, int align_second,
int max_calls,
int (*callback)(const void *pointer,
void *data,
+3 -2
View File
@@ -2264,7 +2264,8 @@ weechat_python_api_hook_timer_cb (const void *pointer, void *data,
API_FUNC(hook_timer)
{
int interval, align_second, max_calls;
long interval;
int align_second, max_calls;
char *function, *data;
const char *result;
@@ -2274,7 +2275,7 @@ API_FUNC(hook_timer)
max_calls = 0;
function = NULL;
data = NULL;
if (!PyArg_ParseTuple (args, "iiiss", &interval, &align_second, &max_calls,
if (!PyArg_ParseTuple (args, "liiss", &interval, &align_second, &max_calls,
&function, &data))
API_WRONG_ARGS(API_RETURN_EMPTY);
+3 -2
View File
@@ -2782,7 +2782,8 @@ static VALUE
weechat_ruby_api_hook_timer (VALUE class, VALUE interval, VALUE align_second,
VALUE max_calls, VALUE function, VALUE data)
{
int c_interval, c_align_second, c_max_calls;
long c_interval;
int c_align_second, c_max_calls;
char *c_function, *c_data;
const char *result;
@@ -2797,7 +2798,7 @@ weechat_ruby_api_hook_timer (VALUE class, VALUE interval, VALUE align_second,
Check_Type (function, T_STRING);
Check_Type (data, T_STRING);
c_interval = NUM2INT (interval);
c_interval = NUM2LONG (interval);
c_align_second = NUM2INT (align_second);
c_max_calls = NUM2INT (max_calls);
c_function = StringValuePtr (function);
+3 -2
View File
@@ -2554,13 +2554,14 @@ API_FUNC(hook_timer)
{
Tcl_Obj *objp;
const char *result;
int i, interval, align_second, max_calls;
long interval;
int i, align_second, max_calls;
API_INIT_FUNC(1, "hook_timer", API_RETURN_EMPTY);
if (objc < 6)
API_WRONG_ARGS(API_RETURN_EMPTY);
if ((Tcl_GetIntFromObj (interp, objv[1], &interval) != TCL_OK)
if ((Tcl_GetLongFromObj (interp, objv[1], &interval) != TCL_OK)
|| (Tcl_GetIntFromObj (interp, objv[2], &align_second) != TCL_OK)
|| (Tcl_GetIntFromObj (interp, objv[3], &max_calls) != TCL_OK))
API_WRONG_ARGS(API_RETURN_EMPTY);
+14
View File
@@ -219,6 +219,11 @@ def command_run_cb(data, buf, command):
return weechat.WEECHAT_RC_OK
def timer_cb(data, remaining_calls):
"""Timer callback."""
return weechat.WEECHAT_RC_OK
def test_hooks():
"""Test function hook_command."""
# hook_completion / hook_completion_args / and hook_command
@@ -237,6 +242,15 @@ def test_hooks():
weechat.unhook(hook_cmd_run)
weechat.unhook(hook_cmd)
weechat.unhook(hook_cmplt)
# hook_timer
hook_timer = weechat.hook_timer(5000111000, 0, 1,
'timer_cb', 'timer_cb_data')
ptr_infolist = weechat.infolist_get('hook', hook_timer, '')
check(ptr_infolist != '')
check(weechat.infolist_next(ptr_infolist) == 1)
check(weechat.infolist_string(ptr_infolist, 'interval') == '5000111000')
weechat.infolist_free(ptr_infolist)
weechat.unhook(hook_timer)
def test_command():