1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-31 06:50:06 +03:00

xmllint: Use proper type to store seconds since epoch

Should avoid year 2038 problem.

Fixes #801.
This commit is contained in:
Nick Wellnhofer 2024-09-26 19:21:24 +02:00
parent 81d38ed069
commit d67833a3c5

View File

@ -337,8 +337,14 @@ myStrdupFunc(const char *str)
* *
************************************************************************/
#ifdef _WIN32
typedef __time64_t xmlSeconds;
#else
typedef time_t xmlSeconds;
#endif
typedef struct {
int sec;
xmlSeconds sec;
int usec;
} xmlTime;
@ -347,11 +353,11 @@ static xmlTime begin, end;
static void
getTime(xmlTime *time) {
#ifdef _WIN32
struct timeb timebuffer;
struct __timeb64 timebuffer;
ftime(&timebuffer);
_ftime64(&timebuffer);
time->sec = timebuffer.time;
time->usec = timebuffer.millitm * 1000L;
time->usec = timebuffer.millitm * 1000;
#else /* _WIN32 */
struct timeval tv;
@ -378,7 +384,7 @@ startTimer(void)
static void LIBXML_ATTR_FORMAT(1,2)
endTimer(const char *fmt, ...)
{
long msec;
xmlSeconds msec;
va_list ap;
getTime(&end);
@ -390,7 +396,7 @@ endTimer(const char *fmt, ...)
vfprintf(ERR_STREAM, fmt, ap);
va_end(ap);
fprintf(ERR_STREAM, " took %ld ms\n", msec);
fprintf(ERR_STREAM, " took %ld ms\n", (long) msec);
}
/************************************************************************