aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2005-11-14 12:07:11 +0000
committerVincent Richard <[email protected]>2005-11-14 12:07:11 +0000
commit1b38cbeb3f2a171c1edfb91692932ec70153a342 (patch)
tree2d47174531624d1cec84b2b73ec252b464ff12d6
parentFixed bug in disconnect() when authentication is not needed (thanks to Benjam... (diff)
downloadvmime-1b38cbeb3f2a171c1edfb91692932ec70153a342.tar.gz
vmime-1b38cbeb3f2a171c1edfb91692932ec70153a342.zip
gmtime() and localtime() are reentrant when using MS C runtime library (MinGW/MSVC).
-rw-r--r--ChangeLog3
-rw-r--r--src/dateTime.cpp13
2 files changed, 15 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 37767e4f..20b90261 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,9 @@ VERSION 0.8.1cvs
* SMTPTransport.cpp: fixed bug in disconnect() when authentication is
not needed (thanks to Benjamin Biron).
+ * dateTime.cpp: gmtime() and localtime() are reentrant when using
+ MS C runtime library (MinGW/MSVC).
+
2005-11-06 Vincent Richard <[email protected]>
* Started version 0.8.1.
diff --git a/src/dateTime.cpp b/src/dateTime.cpp
index ea965805..8b2e33a2 100644
--- a/src/dateTime.cpp
+++ b/src/dateTime.cpp
@@ -648,7 +648,18 @@ datetime::datetime(const datetime& d)
datetime::datetime(const time_t t, const int zone)
{
-#ifdef _REENTRANT
+#if defined(_MSC_VER) || defined(__MINGW32__)
+ // These functions are reentrant in MS C runtime library
+ struct tm* gtm = gmtime(&t);
+ struct tm* ltm = localtime(&t);
+
+ struct tm tms;
+
+ if (gtm)
+ tms = *gtm;
+ else if (ltm)
+ tms = *ltm;
+#elif defined(_REENTRANT)
struct tm tms;
if (!gmtime_r(&t, &tms))