diff --git a/ChangeLog.adoc b/ChangeLog.adoc index e832e6a2c..02a84043e 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -32,6 +32,7 @@ Bug fixes:: * irc: fix display of TOPIC and QUIT messages with an empty trailing parameter (issue #1797) * 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 function infolist_new_var_time (plugins: python/lua/tcl/guile/javascript) * xfer: fix crash when closing DCC chat buffer Tests:: diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index e847f6167..e7a817dbc 100644 --- a/src/plugins/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -4413,7 +4413,7 @@ weechat_guile_api_infolist_new_var_time (SCM item, SCM name, SCM value) result = API_PTR2STR(weechat_infolist_new_var_time (API_STR2PTR(API_SCM_TO_STRING(item)), API_SCM_TO_STRING(name), - scm_to_int (value))); + (time_t)scm_to_long (value))); API_RETURN_STRING(result); } diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp index c042b7775..ec7b2cca4 100644 --- a/src/plugins/javascript/weechat-js-api.cpp +++ b/src/plugins/javascript/weechat-js-api.cpp @@ -4305,10 +4305,10 @@ API_FUNC(infolist_new_var_pointer) API_FUNC(infolist_new_var_time) { - int value; + long value; const char *result; - API_INIT_FUNC(1, "infolist_new_var_time", "ssi", API_RETURN_EMPTY); + API_INIT_FUNC(1, "infolist_new_var_time", "ssn", API_RETURN_EMPTY); v8::String::Utf8Value item(args[0]); v8::String::Utf8Value name(args[1]); @@ -4318,7 +4318,7 @@ API_FUNC(infolist_new_var_time) weechat_infolist_new_var_time ( (struct t_infolist_item *)API_STR2PTR(*item), *name, - value)); + (time_t)value)); API_RETURN_STRING(result); } diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index 678061137..5957f147d 100644 --- a/src/plugins/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -4658,7 +4658,7 @@ API_FUNC(infolist_new_var_time) { const char *item, *name; const char *result; - int value; + long value; API_INIT_FUNC(1, "infolist_new_var_time", API_RETURN_EMPTY); if (lua_gettop (L) < 3) @@ -4670,7 +4670,7 @@ API_FUNC(infolist_new_var_time) result = API_PTR2STR(weechat_infolist_new_var_time (API_STR2PTR(item), name, - value)); + (time_t)value)); API_RETURN_STRING(result); } diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c index 895730620..88b491217 100644 --- a/src/plugins/perl/weechat-perl-api.c +++ b/src/plugins/perl/weechat-perl-api.c @@ -4594,7 +4594,7 @@ API_FUNC(infolist_new_var_time) result = API_PTR2STR(weechat_infolist_new_var_time (API_STR2PTR(item), name, - SvIV (ST (2)))); /* value */ + (time_t)SvIV (ST (2)))); /* value */ API_RETURN_STRING(result); } diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index 3bacf63f7..2251a517b 100644 --- a/src/plugins/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -4540,18 +4540,18 @@ API_FUNC(infolist_new_var_time) { char *item, *name; const char *result; - int value; + long value; API_INIT_FUNC(1, "infolist_new_var_time", API_RETURN_EMPTY); item = NULL; name = NULL; value = 0; - if (!PyArg_ParseTuple (args, "ssi", &item, &name, &value)) + if (!PyArg_ParseTuple (args, "ssl", &item, &name, &value)) API_WRONG_ARGS(API_RETURN_EMPTY); result = API_PTR2STR(weechat_infolist_new_var_time (API_STR2PTR(item), name, - value)); + (time_t)value)); API_RETURN_STRING(result); } diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c index 6e4d2b1d5..13da3f545 100644 --- a/src/plugins/tcl/weechat-tcl-api.c +++ b/src/plugins/tcl/weechat-tcl-api.c @@ -4953,18 +4953,19 @@ API_FUNC(infolist_new_var_time) { Tcl_Obj *objp; const char *result; - int i, value; + int i; + long value; API_INIT_FUNC(1, "infolist_new_var_time", API_RETURN_EMPTY); if (objc < 4) API_WRONG_ARGS(API_RETURN_EMPTY); - if (Tcl_GetIntFromObj (interp, objv[3], &value) != TCL_OK) + if (Tcl_GetLongFromObj (interp, objv[3], &value) != TCL_OK) API_WRONG_ARGS(API_RETURN_EMPTY); result = API_PTR2STR(weechat_infolist_new_var_time (API_STR2PTR(Tcl_GetStringFromObj (objv[1], &i)), /* item */ Tcl_GetStringFromObj (objv[2], &i), /* name */ - value)); + (time_t)value)); API_RETURN_STRING(result); } diff --git a/tests/scripts/python/testapi.py b/tests/scripts/python/testapi.py index 79c0763bb..a9aaffee7 100644 --- a/tests/scripts/python/testapi.py +++ b/tests/scripts/python/testapi.py @@ -244,7 +244,10 @@ def infolist_cb(data, infolist_name, pointer, arguments): check(weechat.infolist_new_var_integer(item, 'integer', 123) != '') check(weechat.infolist_new_var_string(item, 'string', 'test string') != '') check(weechat.infolist_new_var_pointer(item, 'pointer', '0xabcdef') != '') - check(weechat.infolist_new_var_time(item, 'time', 1231231230) != '') + # Tue Jan 06 2009 08:40:30 GMT+0000 + check(weechat.infolist_new_var_time(item, 'time1', 1231231230) != '') + # Tue Jan 06 2150 08:40:30 GMT+0000 + check(weechat.infolist_new_var_time(item, 'time2', 5680744830) != '') return infolist @@ -260,8 +263,9 @@ def test_infolist(): check(weechat.infolist_integer(ptr_infolist, 'integer') == 123) check(weechat.infolist_string(ptr_infolist, 'string') == 'test string') check(weechat.infolist_pointer(ptr_infolist, 'pointer') == '0xabcdef') - check(weechat.infolist_time(ptr_infolist, 'time') == 1231231230) - check(weechat.infolist_fields(ptr_infolist) == 'i:integer,s:string,p:pointer,t:time') + check(weechat.infolist_time(ptr_infolist, 'time1') == 1231231230) + check(weechat.infolist_time(ptr_infolist, 'time2') == 5680744830) + check(weechat.infolist_fields(ptr_infolist) == 'i:integer,s:string,p:pointer,t:time1,t:time2') check(weechat.infolist_next(ptr_infolist) == 0) weechat.infolist_free(ptr_infolist) weechat.unhook(hook_infolist)