diff src/memfile.c @ 9387:f094d4085014 v7.4.1975

commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jul 1 17:17:39 2016 +0200 patch 7.4.1975 Problem: On MS-Windows large files (> 2Gbyte) cause problems. Solution: Use "off_T" instead of "off_t". Use "stat_T" instead of "struct stat". Use 64 bit system functions if available. (Ken Takata)
author Christian Brabandt <cb@256bit.org>
date Fri, 01 Jul 2016 17:30:07 +0200
parents 05b88224cea1
children b2aada04d84e
line wrap: on
line diff
--- a/src/memfile.c
+++ b/src/memfile.c
@@ -81,7 +81,7 @@ static void mf_ins_free(memfile_T *, bhd
 static bhdr_T *mf_rem_free(memfile_T *);
 static int  mf_read(memfile_T *, bhdr_T *);
 static int  mf_write(memfile_T *, bhdr_T *);
-static int  mf_write_block(memfile_T *mfp, bhdr_T *hp, off_t offset, unsigned size);
+static int  mf_write_block(memfile_T *mfp, bhdr_T *hp, off_T offset, unsigned size);
 static int  mf_trans_add(memfile_T *, bhdr_T *);
 static void mf_do_open(memfile_T *, char_u *, int);
 static void mf_hash_init(mf_hashtab_T *);
@@ -124,7 +124,7 @@ static int mf_hash_grow(mf_hashtab_T *);
 mf_open(char_u *fname, int flags)
 {
     memfile_T		*mfp;
-    off_t		size;
+    off_T		size;
 #if defined(STATFS) && defined(UNIX) && !defined(__QNX__) && !defined(__minix)
 # define USE_FSTATFS
     struct STATFS	stf;
@@ -179,7 +179,7 @@ mf_open(char_u *fname, int flags)
 #endif
 
     if (mfp->mf_fd < 0 || (flags & (O_TRUNC|O_EXCL))
-		      || (size = lseek(mfp->mf_fd, (off_t)0L, SEEK_END)) <= 0)
+		  || (size = vim_lseek(mfp->mf_fd, (off_T)0L, SEEK_END)) <= 0)
 	mfp->mf_blocknr_max = 0;	/* no file or empty file */
     else
 	mfp->mf_blocknr_max = (blocknr_T)((size + mfp->mf_page_size - 1)
@@ -966,7 +966,7 @@ mf_rem_free(memfile_T *mfp)
     static int
 mf_read(memfile_T *mfp, bhdr_T *hp)
 {
-    off_t	offset;
+    off_T	offset;
     unsigned	page_size;
     unsigned	size;
 
@@ -974,9 +974,9 @@ mf_read(memfile_T *mfp, bhdr_T *hp)
 	return FAIL;
 
     page_size = mfp->mf_page_size;
-    offset = (off_t)page_size * hp->bh_bnum;
+    offset = (off_T)page_size * hp->bh_bnum;
     size = page_size * hp->bh_page_count;
-    if (lseek(mfp->mf_fd, offset, SEEK_SET) != offset)
+    if (vim_lseek(mfp->mf_fd, offset, SEEK_SET) != offset)
     {
 	PERROR(_("E294: Seek error in swap file read"));
 	return FAIL;
@@ -1005,7 +1005,7 @@ mf_read(memfile_T *mfp, bhdr_T *hp)
     static int
 mf_write(memfile_T *mfp, bhdr_T *hp)
 {
-    off_t	offset;	    /* offset in the file */
+    off_T	offset;	    /* offset in the file */
     blocknr_T	nr;	    /* block nr which is being written */
     bhdr_T	*hp2;
     unsigned	page_size;  /* number of bytes in a page */
@@ -1038,8 +1038,8 @@ mf_write(memfile_T *mfp, bhdr_T *hp)
 	else
 	    hp2 = hp;
 
-	offset = (off_t)page_size * nr;
-	if (lseek(mfp->mf_fd, offset, SEEK_SET) != offset)
+	offset = (off_T)page_size * nr;
+	if (vim_lseek(mfp->mf_fd, offset, SEEK_SET) != offset)
 	{
 	    PERROR(_("E296: Seek error in swap file write"));
 	    return FAIL;
@@ -1083,7 +1083,7 @@ mf_write(memfile_T *mfp, bhdr_T *hp)
 mf_write_block(
     memfile_T	*mfp,
     bhdr_T	*hp,
-    off_t	offset UNUSED,
+    off_T	offset UNUSED,
     unsigned	size)
 {
     char_u	*data = hp->bh_data;
@@ -1247,7 +1247,7 @@ mf_do_open(
     int		flags)		/* flags for open() */
 {
 #ifdef HAVE_LSTAT
-    struct stat sb;
+    stat_T	sb;
 #endif
 
     mfp->mf_fname = fname;