From ab8010ffd7d9536fe9b9cd7cd3ebd1096826e394 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Tue, 19 May 2009 03:48:42 +0000 Subject: [PATCH] #556 timegm() function should work with Windows 64bit time_t Fix submitted. 1) Removed _USE_32BIT_TIME_T from code base. 2) Added a macro to replace timegm() with _mkgmtime() on VC8+ (supports 32 and 64 bit time_t) Simple test performed on VC 7.1/8 and 9 (VS 2003/05/08) C:\gnu\exiv2\msvc\bin\Release>exiv2 -a 1:00:00 ad \R.tiff && exiv2 -pt \R.tiff | grep DateTimeOriginal Exif.Photo.DateTimeOriginal Ascii 20 2009:04:26 10:38:18 C:\gnu\exiv2\msvc\bin\Release>exiv2 -a 1:00:00 ad \R.tiff && exiv2 -pt \R.tiff | grep -i time Exif.Image.DateTimeOriginal Ascii 20 2009:04:26 11:38:18 C:\gnu\exiv2\msvc\bin\Release> 3) Cosmetic fix to basicio.cpp Fixed nasty little I missed when I committed basicio.cpp on Sunday (apologies) --- src/basicio.cpp | 2 +- src/localtime.c | 8 ++++++++ src/timegm.h | 11 ++++++----- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/basicio.cpp b/src/basicio.cpp index e81e5768..24815e0c 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -383,7 +383,7 @@ namespace Exiv2 { int FileIo::close() { - munmap(); + munmap(); if (fp_ != 0) { std::fclose(fp_); fp_= 0; diff --git a/src/localtime.c b/src/localtime.c index 6bbca8c2..502ae9d3 100644 --- a/src/localtime.c +++ b/src/localtime.c @@ -1412,6 +1412,9 @@ const long offset; /* ahu: deleted definition of timelocal */ +/* rmills - timegm is replaced with _mkgmtime on VC 2005 and up */ +/* - see timegm.h */ +#if !defined(_MSC_VER) || (_MSC_VER < 1400) time_t timegm(tmp) struct tm * const tmp; @@ -1419,6 +1422,11 @@ struct tm * const tmp; tmp->tm_isdst = 0; return time1(tmp, gmtsub, 0L); } +#endif + + + + /* ahu: deleted definition of timeoff */ diff --git a/src/timegm.h b/src/timegm.h index 153ec15e..e9592c6d 100644 --- a/src/timegm.h +++ b/src/timegm.h @@ -6,11 +6,6 @@ #ifndef TIMEGM_H_ #define TIMEGM_H_ -/* Visual Studio C++ 2005 (8.0) uses 64 bit time_t, which doesn't work */ -#if defined _MSC_VER && _MSC_VER >= 1400 -# define _USE_32BIT_TIME_T -#endif - #include /* @@ -84,7 +79,13 @@ extern "C" { #endif // The UTC version of mktime +/* rmills - timegm is replaced with _mkgmtime on VC 2005 and up */ +/* - see localtime.c */ +#if !defined(_MSC_VER) || (_MSC_VER < 1400) time_t timegm(struct tm * const tmp); +#else +#define timegm _mkgmtime +#endif #ifdef __cplusplus }