[Box Backup-commit] COMMIT r1564 - box/chris/general/lib/common
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Sun, 22 Apr 2007 16:43:23 +0100
Author: chris
Date: 2007-04-22 16:43:23 +0100 (Sun, 22 Apr 2007)
New Revision: 1564
Modified:
box/chris/general/lib/common/Logging.cpp
Log:
Compile fix for Win32, where no localtime_r is available and localtime
is thread safe.
Modified: box/chris/general/lib/common/Logging.cpp
===================================================================
--- box/chris/general/lib/common/Logging.cpp 2007-04-22 15:16:50 UTC (rev 1563)
+++ box/chris/general/lib/common/Logging.cpp 2007-04-22 15:43:23 UTC (rev 1564)
@@ -210,7 +210,7 @@
if (sShowTime)
{
- struct tm time_now;
+ struct tm time_now, *tm_ptr = &time_now;
time_t time_t_now = time(NULL);
if (time_t_now == ((time_t)-1))
@@ -218,13 +218,17 @@
msg += strerror(errno);
msg += " ";
}
- else if (localtime_r(&time_t_now, &time_now) != NULL)
+ #ifdef WIN32
+ else if ((tm_ptr = localtime(&time_t_now)) != NULL)
+ #else
+ else if (localtime_r(&time_t_now, &time_now) != NULL)
+ #endif
{
std::ostringstream buf;
buf << std::setfill('0') <<
- std::setw(2) << time_now.tm_hour << ":" <<
- std::setw(2) << time_now.tm_min << ":" <<
- std::setw(2) << time_now.tm_sec << " ";
+ std::setw(2) << tm_ptr->tm_hour << ":" <<
+ std::setw(2) << tm_ptr->tm_min << ":" <<
+ std::setw(2) << tm_ptr->tm_sec << " ";
msg += buf.str();
}
else