Skip to content

Commit 0bd4051

Browse files
committed
patch 8.1.0423: MS-Windows: using dup-close for flushing a file
Problem: MS-Windows: using dup-close for flushing a file. Solution: Use _commit(). (Ken Takata, closes #3463)
1 parent 4ff4290 commit 0bd4051

4 files changed

Lines changed: 5 additions & 12 deletions

File tree

src/memfile.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,6 @@ mf_sync(memfile_T *mfp, int flags)
539539
{
540540
int status;
541541
bhdr_T *hp;
542-
#if defined(SYNC_DUP_CLOSE)
543-
int fd;
544-
#endif
545542
int got_int_save = got_int;
546543

547544
if (mfp->mf_fd < 0) /* there is no file, nothing to do */
@@ -624,13 +621,9 @@ mf_sync(memfile_T *mfp, int flags)
624621
status = FAIL;
625622
}
626623
#endif
627-
#ifdef SYNC_DUP_CLOSE
628-
/*
629-
* Win32 is a bit more work: Duplicate the file handle and close it.
630-
* This should flush the file to disk.
631-
*/
632-
if ((fd = dup(mfp->mf_fd)) >= 0)
633-
close(fd);
624+
#ifdef WIN32
625+
if (_commit(mfp->mf_fd))
626+
status = FAIL;
634627
#endif
635628
#ifdef AMIGA
636629
# if defined(__AROS__) || defined(__amigaos4__)

src/os_mac.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@
101101
#define HAVE_AVAIL_MEM
102102

103103
#ifndef HAVE_CONFIG_H
104-
/* #define SYNC_DUP_CLOSE sync() a file with dup() and close() */
105104
# define HAVE_STRING_H
106105
# define HAVE_STRCSPN
107106
# define HAVE_MEMSET

src/os_win32.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
#define BINARY_FILE_IO
2828
#define USE_EXE_NAME /* use argv[0] for $VIM */
29-
#define SYNC_DUP_CLOSE /* sync() a file with dup() and close() */
3029
#define USE_TERM_CONSOLE
3130
#ifndef HAVE_STRING_H
3231
# define HAVE_STRING_H

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,8 @@ static char *(features[]) =
794794

795795
static int included_patches[] =
796796
{ /* Add new patch number below this line */
797+
/**/
798+
423,
797799
/**/
798800
422,
799801
/**/

0 commit comments

Comments
 (0)