mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 21:06:38 +02:00
scripts: fix issue with year ≥ 2038 in functions print_date_tags and print_y_date_tags
Affected plugins: python, lua, tcl, guile, javascript.
This commit is contained in:
+1
-1
@@ -32,7 +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)
|
||||
* 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)
|
||||
* xfer: fix crash when closing DCC chat buffer
|
||||
|
||||
Tests::
|
||||
|
||||
@@ -1902,7 +1902,7 @@ weechat_guile_api_print_date_tags (SCM buffer, SCM date, SCM tags, SCM message)
|
||||
plugin_script_api_printf_date_tags (weechat_guile_plugin,
|
||||
guile_current_script,
|
||||
API_STR2PTR(API_SCM_TO_STRING(buffer)),
|
||||
scm_to_int (date),
|
||||
(time_t)scm_to_long (date),
|
||||
API_SCM_TO_STRING(tags),
|
||||
"%s", API_SCM_TO_STRING(message));
|
||||
|
||||
@@ -1940,7 +1940,7 @@ weechat_guile_api_print_y_date_tags (SCM buffer, SCM y, SCM date, SCM tags,
|
||||
guile_current_script,
|
||||
API_STR2PTR(API_SCM_TO_STRING(buffer)),
|
||||
scm_to_int (y),
|
||||
scm_to_int (date),
|
||||
(time_t)scm_to_long (date),
|
||||
API_SCM_TO_STRING(tags),
|
||||
"%s", API_SCM_TO_STRING(message));
|
||||
|
||||
|
||||
@@ -1787,9 +1787,9 @@ API_FUNC(print)
|
||||
|
||||
API_FUNC(print_date_tags)
|
||||
{
|
||||
int date;
|
||||
long date;
|
||||
|
||||
API_INIT_FUNC(1, "print_date_tags", "siss", API_RETURN_ERROR);
|
||||
API_INIT_FUNC(1, "print_date_tags", "snss", API_RETURN_ERROR);
|
||||
|
||||
v8::String::Utf8Value buffer(args[0]);
|
||||
date = args[1]->IntegerValue();
|
||||
@@ -1800,7 +1800,7 @@ API_FUNC(print_date_tags)
|
||||
weechat_js_plugin,
|
||||
js_current_script,
|
||||
(struct t_gui_buffer *)API_STR2PTR(*buffer),
|
||||
date,
|
||||
(time_t)date,
|
||||
*tags,
|
||||
"%s", *message);
|
||||
|
||||
@@ -1828,9 +1828,10 @@ API_FUNC(print_y)
|
||||
|
||||
API_FUNC(print_y_date_tags)
|
||||
{
|
||||
int y, date;
|
||||
int y;
|
||||
long date;
|
||||
|
||||
API_INIT_FUNC(1, "print_y_date_tags", "siiss", API_RETURN_ERROR);
|
||||
API_INIT_FUNC(1, "print_y_date_tags", "sinss", API_RETURN_ERROR);
|
||||
|
||||
v8::String::Utf8Value buffer(args[0]);
|
||||
y = args[1]->IntegerValue();
|
||||
@@ -1842,7 +1843,7 @@ API_FUNC(print_y_date_tags)
|
||||
js_current_script,
|
||||
(struct t_gui_buffer *)API_STR2PTR(*buffer),
|
||||
y,
|
||||
date,
|
||||
(time_t)date,
|
||||
*tags,
|
||||
"%s", *message);
|
||||
|
||||
|
||||
@@ -1981,7 +1981,7 @@ API_FUNC(print)
|
||||
API_FUNC(print_date_tags)
|
||||
{
|
||||
const char *buffer, *tags, *message;
|
||||
int date;
|
||||
long date;
|
||||
|
||||
API_INIT_FUNC(1, "print_date_tags", API_RETURN_ERROR);
|
||||
if (lua_gettop (L) < 4)
|
||||
@@ -1995,7 +1995,7 @@ API_FUNC(print_date_tags)
|
||||
plugin_script_api_printf_date_tags (weechat_lua_plugin,
|
||||
lua_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
date,
|
||||
(time_t)date,
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
@@ -2027,7 +2027,8 @@ API_FUNC(print_y)
|
||||
API_FUNC(print_y_date_tags)
|
||||
{
|
||||
const char *buffer, *tags, *message;
|
||||
int y, date;
|
||||
int y;
|
||||
long date;
|
||||
|
||||
API_INIT_FUNC(1, "print_y_date_tags", API_RETURN_ERROR);
|
||||
if (lua_gettop (L) < 5)
|
||||
@@ -2043,7 +2044,7 @@ API_FUNC(print_y_date_tags)
|
||||
lua_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
y,
|
||||
date,
|
||||
(time_t)date,
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
|
||||
@@ -1909,7 +1909,7 @@ API_FUNC(print_date_tags)
|
||||
plugin_script_api_printf_date_tags (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
SvIV (ST (1)),
|
||||
(time_t)(SvIV (ST (1))), /* date */
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
@@ -1953,8 +1953,8 @@ API_FUNC(print_y_date_tags)
|
||||
plugin_script_api_printf_y_date_tags (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
SvIV (ST (1)),
|
||||
SvIV (ST (2)),
|
||||
SvIV (ST (1)), /* y */
|
||||
(time_t)(SvIV (ST (2))), /* date */
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
@@ -4594,7 +4594,7 @@ API_FUNC(infolist_new_var_time)
|
||||
|
||||
result = API_PTR2STR(weechat_infolist_new_var_time (API_STR2PTR(item),
|
||||
name,
|
||||
(time_t)SvIV (ST (2)))); /* value */
|
||||
(time_t)(SvIV (ST (2))))); /* value */
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
@@ -1889,20 +1889,20 @@ API_FUNC(prnt)
|
||||
API_FUNC(prnt_date_tags)
|
||||
{
|
||||
char *buffer, *tags, *message;
|
||||
int date;
|
||||
long date;
|
||||
|
||||
API_INIT_FUNC(1, "prnt_date_tags", API_RETURN_ERROR);
|
||||
buffer = NULL;
|
||||
date = 0;
|
||||
tags = NULL;
|
||||
message = NULL;
|
||||
if (!PyArg_ParseTuple (args, "siss", &buffer, &date, &tags, &message))
|
||||
if (!PyArg_ParseTuple (args, "slss", &buffer, &date, &tags, &message))
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
plugin_script_api_printf_date_tags (weechat_python_plugin,
|
||||
python_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
date,
|
||||
(time_t)date,
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
@@ -1933,7 +1933,8 @@ API_FUNC(prnt_y)
|
||||
API_FUNC(prnt_y_date_tags)
|
||||
{
|
||||
char *buffer, *tags, *message;
|
||||
int y, date;
|
||||
int y;
|
||||
long date;
|
||||
|
||||
API_INIT_FUNC(1, "prnt_y_date_tags", API_RETURN_ERROR);
|
||||
buffer = NULL;
|
||||
@@ -1941,14 +1942,14 @@ API_FUNC(prnt_y_date_tags)
|
||||
date = 0;
|
||||
tags = NULL;
|
||||
message = NULL;
|
||||
if (!PyArg_ParseTuple (args, "siiss", &buffer, &y, &date, &tags, &message))
|
||||
if (!PyArg_ParseTuple (args, "silss", &buffer, &y, &date, &tags, &message))
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
plugin_script_api_printf_y_date_tags (weechat_python_plugin,
|
||||
python_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
y,
|
||||
date,
|
||||
(time_t)date,
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
|
||||
@@ -2146,13 +2146,14 @@ API_FUNC(print_date_tags)
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *buffer, *tags, *message;
|
||||
int i, date;
|
||||
int i;
|
||||
long date;
|
||||
|
||||
API_INIT_FUNC(1, "print_date_tags", API_RETURN_ERROR);
|
||||
if (objc < 5)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
if (Tcl_GetIntFromObj (interp, objv[2], &date) != TCL_OK)
|
||||
if (Tcl_GetLongFromObj (interp, objv[2], &date) != TCL_OK)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
buffer = Tcl_GetStringFromObj (objv[1], &i);
|
||||
@@ -2162,7 +2163,7 @@ API_FUNC(print_date_tags)
|
||||
plugin_script_api_printf_date_tags (weechat_tcl_plugin,
|
||||
tcl_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
date,
|
||||
(time_t)date,
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
@@ -2198,7 +2199,8 @@ API_FUNC(print_y_date_tags)
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *buffer, *tags, *message;
|
||||
int i, y, date;
|
||||
int i, y;
|
||||
long date;
|
||||
|
||||
API_INIT_FUNC(1, "print_y_date_tags", API_RETURN_ERROR);
|
||||
if (objc < 6)
|
||||
@@ -2207,7 +2209,7 @@ API_FUNC(print_y_date_tags)
|
||||
if (Tcl_GetIntFromObj (interp, objv[2], &y) != TCL_OK)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
if (Tcl_GetIntFromObj (interp, objv[3], &date) != TCL_OK)
|
||||
if (Tcl_GetLongFromObj (interp, objv[3], &date) != TCL_OK)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
buffer = Tcl_GetStringFromObj (objv[1], &i);
|
||||
@@ -2218,7 +2220,7 @@ API_FUNC(print_y_date_tags)
|
||||
tcl_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
y,
|
||||
date,
|
||||
(time_t)date,
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
|
||||
@@ -170,6 +170,16 @@ def test_display():
|
||||
check(weechat.color('unknown') == '')
|
||||
weechat.prnt('', '## test print core buffer')
|
||||
weechat.prnt_date_tags('', 946681200, 'tag1,tag2', '## test print_date_tags core buffer')
|
||||
weechat.prnt_date_tags('', 5680744830, 'tag1,tag2', '## test print_date_tags core buffer, year 2150')
|
||||
hdata_buffer = weechat.hdata_get('buffer')
|
||||
hdata_lines = weechat.hdata_get('lines')
|
||||
hdata_line = weechat.hdata_get('line')
|
||||
hdata_line_data = weechat.hdata_get('line_data')
|
||||
buffer = weechat.buffer_search_main()
|
||||
own_lines = weechat.hdata_pointer(hdata_buffer, buffer, 'own_lines')
|
||||
line = weechat.hdata_pointer(hdata_lines, own_lines, 'last_line')
|
||||
data = weechat.hdata_pointer(hdata_line, line, 'data')
|
||||
check(weechat.hdata_time(hdata_line_data, data, 'date') == 5680744830)
|
||||
buffer = weechat.buffer_new('test_formatted', 'buffer_input_cb', '', 'buffer_close_cb', '')
|
||||
check(buffer != '')
|
||||
check(weechat.buffer_get_integer(buffer, 'type') == 0)
|
||||
@@ -181,6 +191,7 @@ def test_display():
|
||||
check(buffer != '')
|
||||
weechat.prnt_y(buffer, 0, '## test print_y free buffer')
|
||||
weechat.prnt_y_date_tags(buffer, 0, 946681200, 'tag1,tag2', '## test print_y_date_tags free buffer')
|
||||
weechat.prnt_y_date_tags(buffer, 1, 5680744830, 'tag1,tag2', '## test print_y_date_tags free buffer, year 2150')
|
||||
weechat.buffer_close(buffer)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user