diff src/misc2.c @ 9347:25c562442f8c v7.4.1955

commit https://github.com/vim/vim/commit/f4fba6dcd508cb369ffa6916d9cb3fcf3d7ed548 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 26 16:44:24 2016 +0200 patch 7.4.1955 Problem: Using 32-bit Perl with 64-bit time_t causes memory corruption. (Christian Brabandt) Solution: Use time_T instead of time_t for global variables. (Ken Takata)
author Christian Brabandt <cb@256bit.org>
date Sun, 26 Jun 2016 16:45:05 +0200
parents c25898cc99c1
children b88c573d8aa4
line wrap: on
line diff
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -6070,12 +6070,12 @@ get4c(FILE *fd)
 }
 
 /*
- * Read 8 bytes from "fd" and turn them into a time_t, MSB first.
+ * Read 8 bytes from "fd" and turn them into a time_T, MSB first.
  */
-    time_t
+    time_T
 get8ctime(FILE *fd)
 {
-    time_t	n = 0;
+    time_T	n = 0;
     int		i;
 
     for (i = 0; i < 8; ++i)
@@ -6137,11 +6137,11 @@ put_bytes(FILE *fd, long_u nr, int len)
 #endif
 
 /*
- * Write time_t to file "fd" in 8 bytes.
+ * Write time_T to file "fd" in 8 bytes.
  * Returns FAIL when the write failed.
  */
     int
-put_time(FILE *fd, time_t the_time)
+put_time(FILE *fd, time_T the_time)
 {
     char_u	buf[8];
 
@@ -6150,26 +6150,26 @@ put_time(FILE *fd, time_t the_time)
 }
 
 /*
- * Write time_t to "buf[8]".
+ * Write time_T to "buf[8]".
  */
     void
-time_to_bytes(time_t the_time, char_u *buf)
+time_to_bytes(time_T the_time, char_u *buf)
 {
     int		c;
     int		i;
     int		bi = 0;
-    time_t	wtime = the_time;
-
-    /* time_t can be up to 8 bytes in size, more than long_u, thus we
+    time_T	wtime = the_time;
+
+    /* time_T can be up to 8 bytes in size, more than long_u, thus we
      * can't use put_bytes() here.
      * Another problem is that ">>" may do an arithmetic shift that keeps the
      * sign.  This happens for large values of wtime.  A cast to long_u may
-     * truncate if time_t is 8 bytes.  So only use a cast when it is 4 bytes,
+     * truncate if time_T is 8 bytes.  So only use a cast when it is 4 bytes,
      * it's safe to assume that long_u is 4 bytes or more and when using 8
      * bytes the top bit won't be set. */
     for (i = 7; i >= 0; --i)
     {
-	if (i + 1 > (int)sizeof(time_t))
+	if (i + 1 > (int)sizeof(time_T))
 	    /* ">>" doesn't work well when shifting more bits than avail */
 	    buf[bi++] = 0;
 	else