aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2016-10-17 10:25:58 +0300
committerEli Zaretskii2016-10-17 10:25:58 +0300
commitd70ed8aaeae8529813f591ce548631e424d853a2 (patch)
tree067357c6f24079ea2d4a0544830fcb863f65a543
parent99892eeec8990884ef38601f14038ec6dc227741 (diff)
downloademacs-d70ed8aaeae8529813f591ce548631e424d853a2.tar.gz
emacs-d70ed8aaeae8529813f591ce548631e424d853a2.zip
Fix time-related data types in 2 editfns.c functions
* src/editfns.c (format_time_string, Fcurrent_time_zone): Pass a pointer to time_t value to emacs_localtime_rz and gmtime_r, instead of relying on struct timespec's tv_sec member to be of compatible type.
-rw-r--r--src/editfns.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 4e90dad568f..403569f1fcd 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2054,7 +2054,11 @@ format_time_string (char const *format, ptrdiff_t formatlen,
2054 USE_SAFE_ALLOCA; 2054 USE_SAFE_ALLOCA;
2055 2055
2056 timezone_t tz = tzlookup (zone, false); 2056 timezone_t tz = tzlookup (zone, false);
2057 tmp = emacs_localtime_rz (tz, &t.tv_sec, tmp); 2057 /* On some systems, like 32-bit MinGW, tv_sec of struct timespec is
2058 a 64-bit type, but time_t is a 32-bit type. emacs_localtime_rz
2059 expects a pointer to time_t value. */
2060 time_t tsec = t.tv_sec;
2061 tmp = emacs_localtime_rz (tz, &tsec, tmp);
2058 if (! tmp) 2062 if (! tmp)
2059 { 2063 {
2060 xtzfree (tz); 2064 xtzfree (tz);
@@ -2313,7 +2317,10 @@ the data it can't find. */)
2313 zone_name = format_time_string ("%Z", sizeof "%Z" - 1, value, 2317 zone_name = format_time_string ("%Z", sizeof "%Z" - 1, value,
2314 zone, &local_tm); 2318 zone, &local_tm);
2315 2319
2316 if (HAVE_TM_GMTOFF || gmtime_r (&value.tv_sec, &gmt_tm)) 2320 /* gmtime_r expects a pointer to time_t, but tv_sec of struct
2321 timespec on some systems (MinGW) is a 64-bit field. */
2322 time_t tsec = value.tv_sec;
2323 if (HAVE_TM_GMTOFF || gmtime_r (&tsec, &gmt_tm))
2317 { 2324 {
2318 long int offset = (HAVE_TM_GMTOFF 2325 long int offset = (HAVE_TM_GMTOFF
2319 ? tm_gmtoff (&local_tm) 2326 ? tm_gmtoff (&local_tm)