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

core, irc: replace "long" by "long long" to store seconds in timeval structure

This commit is contained in:
Sébastien Helleu
2025-03-16 14:05:11 +01:00
parent 764b309e92
commit ca22e49041
3 changed files with 11 additions and 11 deletions
+4 -4
View File
@@ -288,7 +288,7 @@ util_parse_time (const char *datetime, struct timeval *tv)
char *string, *pos, *pos2, str_usec[16], *error, str_date[128];
struct tm tm_date, tm_date_gm, tm_date_local, *local_time;
time_t time_now, time_gm, time_local;
long value;
long long value;
int rc, length, use_local_time, timezone_offset, offset_factor, hour, min;
if (!datetime || !datetime[0] || !tv)
@@ -330,14 +330,14 @@ util_parse_time (const char *datetime, struct timeval *tv)
strcat (str_usec, "0");
}
error = NULL;
value = strtol (str_usec, &error, 10);
value = strtoll (str_usec, &error, 10);
if (error && !error[0])
{
if (value < 0)
value = 0;
else if (value > 999999)
value = 999999;
tv->tv_usec = (int)value;
tv->tv_usec = (long)value;
}
}
memmove (pos, pos2, strlen (pos2) + 1);
@@ -474,7 +474,7 @@ util_parse_time (const char *datetime, struct timeval *tv)
{
/* timestamp format: "1704402062" */
error = NULL;
value = strtol (string, &error, 10);
value = strtoll (string, &error, 10);
if (error && !error[0] && (value >= 0))
{
tv->tv_sec = (time_t)value;
+4 -4
View File
@@ -1395,7 +1395,7 @@ gui_chat_hsignal_quote_line_cb (const void *pointer, void *data,
struct t_hashtable *hashtable)
{
const char *ptr_date, *ptr_date_usec, *line, *prefix, *ptr_prefix, *message;
long number;
long long number;
struct timeval tv;
struct t_gui_line *ptr_line;
int is_nick, rc;
@@ -1415,7 +1415,7 @@ gui_chat_hsignal_quote_line_cb (const void *pointer, void *data,
if (ptr_date)
{
error = NULL;
number = strtol (ptr_date, &error, 10);
number = strtoll (ptr_date, &error, 10);
if (error && !error[0])
{
tv.tv_sec = (time_t)number;
@@ -1425,9 +1425,9 @@ gui_chat_hsignal_quote_line_cb (const void *pointer, void *data,
if (ptr_date_usec)
{
error = NULL;
number = strtol (ptr_date_usec, &error, 10);
number = strtoll (ptr_date_usec, &error, 10);
if (error && !error[0])
tv.tv_usec = (int)number;
tv.tv_usec = (long)number;
}
util_strftimeval (str_time, sizeof (str_time),
CONFIG_STRING(config_look_quote_time_format),
+3 -3
View File
@@ -253,7 +253,7 @@ irc_ctcp_display_reply_from_nick (struct t_irc_protocol_ctxt *ctxt,
{
char *dup_arguments, *ptr_args, *pos_end, *pos_space, *pos_args, *pos_usec;
struct timeval tv;
long sec1, usec1, sec2, usec2, difftime;
long long sec1, usec1, sec2, usec2, difftime;
dup_arguments = strdup (arguments);
if (!dup_arguments)
@@ -284,8 +284,8 @@ irc_ctcp_display_reply_from_nick (struct t_irc_protocol_ctxt *ctxt,
pos_usec[0] = '\0';
gettimeofday (&tv, NULL);
sec1 = atol (pos_args);
usec1 = atol (pos_usec + 1);
sec1 = atoll (pos_args);
usec1 = atoll (pos_usec + 1);
sec2 = tv.tv_sec;
usec2 = tv.tv_usec;