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

perl: fix conversion of dates in the API functions

On modern 32-bit platforms with a 64-bit time_t, the value returned by SvIV can
be 32-bit (its width depends on how Perl was built), whereas time_t is 64-bit.

Read the date with SvNV instead: a double represents all real timestamps
exactly, so the conversion to time_t no longer depends on the size of the Perl
integer type.
This commit is contained in:
Sébastien Helleu
2026-06-21 07:45:22 +02:00
parent 1dd423cb23
commit a5404172c8
2 changed files with 6 additions and 6 deletions
+5 -5
View File
@@ -2106,7 +2106,7 @@ API_FUNC(print_date_tags)
plugin_script_api_printf_date_tags (weechat_perl_plugin,
perl_current_script,
API_STR2PTR(buffer),
(time_t)(SvIV (ST (1))), /* date */
(time_t)(SvNV (ST (1))), /* date */
tags,
"%s", message);
@@ -2129,7 +2129,7 @@ API_FUNC(print_datetime_tags)
plugin_script_api_printf_datetime_tags (weechat_perl_plugin,
perl_current_script,
API_STR2PTR(buffer),
(time_t)(SvIV (ST (1))), /* date */
(time_t)(SvNV (ST (1))), /* date */
SvIV (ST (2)), /* date_usec */
tags,
"%s", message);
@@ -2175,7 +2175,7 @@ API_FUNC(print_y_date_tags)
perl_current_script,
API_STR2PTR(buffer),
SvIV (ST (1)), /* y */
(time_t)(SvIV (ST (2))), /* date */
(time_t)(SvNV (ST (2))), /* date */
tags,
"%s", message);
@@ -2199,7 +2199,7 @@ API_FUNC(print_y_datetime_tags)
perl_current_script,
API_STR2PTR(buffer),
SvIV (ST (1)), /* y */
(time_t)(SvIV (ST (2))), /* date */
(time_t)(SvNV (ST (2))), /* date */
SvIV (ST (3)), /* date_usec */
tags,
"%s", message);
@@ -4940,7 +4940,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)(SvNV (ST (2))))); /* value */
API_RETURN_STRING(result);
}