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

core: fix tests on function strftimeval on Alpine

This commit is contained in:
Sébastien Helleu
2024-03-24 20:56:29 +01:00
parent fe14cedf92
commit 3d5d5a64ee
3 changed files with 24 additions and 12 deletions
+4
View File
@@ -25,6 +25,10 @@ Bug fixes::
* tcl: fix truncation of long integer returned by function hdata_long
* trigger: fix memory leak when adding a new trigger with `/trigger` command
Tests::
* core: fix tests on function strftimeval on Alpine
[[v4.2.1]]
== Version 4.2.1 (2024-01-22)
+16 -8
View File
@@ -198,15 +198,23 @@ util_strftimeval (char *string, int max, const char *format, struct timeval *tv)
string_dyn_concat (format2, "%%", -1);
ptr_format += 2;
}
else if ((ptr_format[0] == '%') && (ptr_format[1] == '.')
&& (ptr_format[2] >= '1') && (ptr_format[2] <= '6'))
else if ((ptr_format[0] == '%') && (ptr_format[1] == '.'))
{
snprintf (str_usec, sizeof (str_usec),
"%06ld", (long)(tv->tv_usec));
length = ptr_format[2] - '1' + 1;
str_usec[length] = '\0';
string_dyn_concat (format2, str_usec, -1);
ptr_format += 3;
if ((ptr_format[2] >= '1') && (ptr_format[2] <= '6'))
{
snprintf (str_usec, sizeof (str_usec),
"%06ld", (long)(tv->tv_usec));
length = ptr_format[2] - '1' + 1;
str_usec[length] = '\0';
string_dyn_concat (format2, str_usec, -1);
ptr_format += 3;
}
else
{
ptr_format += 2;
if (ptr_format[0])
ptr_format++;
}
}
else if ((ptr_format[0] == '%') && (ptr_format[1] == 'f'))
{
+4 -4
View File
@@ -229,13 +229,13 @@ TEST(CoreUtil, Strftimeval)
/* invalid microseconds digits (must be 1-6) */
strcpy (str_time, "test");
LONGS_EQUAL(23, util_strftimeval (str_time, sizeof (str_time),
LONGS_EQUAL(20, util_strftimeval (str_time, sizeof (str_time),
"%Y-%m-%d %H:%M:%S.%.0", &tv));
STRCMP_EQUAL("2023-12-25 10:29:09.%.0", str_time);
STRCMP_EQUAL("2023-12-25 10:29:09.", str_time);
strcpy (str_time, "test");
LONGS_EQUAL(23, util_strftimeval (str_time, sizeof (str_time),
LONGS_EQUAL(20, util_strftimeval (str_time, sizeof (str_time),
"%Y-%m-%d %H:%M:%S.%.7", &tv));
STRCMP_EQUAL("2023-12-25 10:29:09.%.7", str_time);
STRCMP_EQUAL("2023-12-25 10:29:09.", str_time);
}
/*