aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2016-10-17 10:19:34 +0300
committerEli Zaretskii2016-10-17 10:19:34 +0300
commitbe0c3814af555f6149ab030be23a32b447d485f4 (patch)
tree8244ba5d956db63982b8b54d718a8ced013eaa78 /src
parent665ee0a56551ad897a9e5092ebc91728c98a2d43 (diff)
downloademacs-be0c3814af555f6149ab030be23a32b447d485f4.tar.gz
emacs-be0c3814af555f6149ab030be23a32b447d485f4.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.
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/editfns.c b/src/editfns.c
index dcb1d8d6b88..4f6108102db 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2085,7 +2085,11 @@ format_time_string (char const *format, ptrdiff_t formatlen,
2085 USE_SAFE_ALLOCA; 2085 USE_SAFE_ALLOCA;
2086 2086
2087 timezone_t tz = tzlookup (zone, false); 2087 timezone_t tz = tzlookup (zone, false);
2088 tmp = emacs_localtime_rz (tz, &t.tv_sec, tmp); 2088 /* On some systems, like 32-bit MinGW, tv_sec of struct timespec is
2089 a 64-bit type, but time_t is a 32-bit type. emacs_localtime_rz
2090 expects a pointer to time_t value. */
2091 time_t tsec = t.tv_sec;
2092 tmp = emacs_localtime_rz (tz, &tsec, tmp);
2089 if (! tmp) 2093 if (! tmp)
2090 { 2094 {
2091 xtzfree (tz); 2095 xtzfree (tz);
@@ -2353,7 +2357,10 @@ the data it can't find. */)
2353 zone_name = format_time_string ("%Z", sizeof "%Z" - 1, value, 2357 zone_name = format_time_string ("%Z", sizeof "%Z" - 1, value,
2354 zone, &local_tm); 2358 zone, &local_tm);
2355 2359
2356 if (HAVE_TM_GMTOFF || gmtime_r (&value.tv_sec, &gmt_tm)) 2360 /* gmtime_r expects a pointer to time_t, but tv_sec of struct
2361 timespec on some systems (MinGW) is a 64-bit field. */
2362 time_t tsec = value.tv_sec;
2363 if (HAVE_TM_GMTOFF || gmtime_r (&tsec, &gmt_tm))
2357 { 2364 {
2358 long int offset = (HAVE_TM_GMTOFF 2365 long int offset = (HAVE_TM_GMTOFF
2359 ? tm_gmtoff (&local_tm) 2366 ? tm_gmtoff (&local_tm)