To: vim_dev@googlegroups.com Subject: Patch 7.4.1139 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1139 Problem: MS-Windows: getftype() returns "file for symlink to directory. Solution: Make it return "dir". (Ken Takata) Files: src/os_mswin.c *** ../vim-7.4.1138/src/os_mswin.c 2015-10-13 19:43:14.140511991 +0200 --- src/os_mswin.c 2016-01-19 18:57:58.317246524 +0100 *************** *** 506,517 **** static int stat_symlink_aware(const char *name, struct stat *stp) { ! #if defined(_MSC_VER) && _MSC_VER < 1700 ! /* Work around for VC10 or earlier. stat() can't handle symlinks properly. * VC9 or earlier: stat() doesn't support a symlink at all. It retrieves * status of a symlink itself. * VC10: stat() supports a symlink to a normal file, but it doesn't support ! * a symlink to a directory (always returns an error). */ WIN32_FIND_DATA findData; HANDLE hFind, h; DWORD attr = 0; --- 506,521 ---- static int stat_symlink_aware(const char *name, struct stat *stp) { ! #if (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__MINGW32__) ! /* Work around for VC12 or earlier (and MinGW). stat() can't handle ! * symlinks properly. * VC9 or earlier: stat() doesn't support a symlink at all. It retrieves * status of a symlink itself. * VC10: stat() supports a symlink to a normal file, but it doesn't support ! * a symlink to a directory (always returns an error). ! * VC11 and VC12: stat() doesn't return an error for a symlink to a ! * directory, but it doesn't set S_IFDIR flag. ! * MinGW: Same as VC9. */ WIN32_FIND_DATA findData; HANDLE hFind, h; DWORD attr = 0; *************** *** 540,545 **** --- 544,551 ---- fd = _open_osfhandle((OPEN_OH_ARGTYPE)h, _O_RDONLY); n = _fstat(fd, (struct _stat*)stp); + if ((n == 0) && (attr & FILE_ATTRIBUTE_DIRECTORY)) + stp->st_mode = (stp->st_mode & ~S_IFREG) | S_IFDIR; _close(fd); return n; } *************** *** 552,563 **** static int wstat_symlink_aware(const WCHAR *name, struct _stat *stp) { ! # if defined(_MSC_VER) && _MSC_VER < 1700 ! /* Work around for VC10 or earlier. _wstat() can't handle symlinks properly. * VC9 or earlier: _wstat() doesn't support a symlink at all. It retrieves * status of a symlink itself. * VC10: _wstat() supports a symlink to a normal file, but it doesn't ! * support a symlink to a directory (always returns an error). */ int n; BOOL is_symlink = FALSE; HANDLE hFind, h; --- 558,573 ---- static int wstat_symlink_aware(const WCHAR *name, struct _stat *stp) { ! # if (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__MINGW32__) ! /* Work around for VC12 or earlier (and MinGW). _wstat() can't handle ! * symlinks properly. * VC9 or earlier: _wstat() doesn't support a symlink at all. It retrieves * status of a symlink itself. * VC10: _wstat() supports a symlink to a normal file, but it doesn't ! * support a symlink to a directory (always returns an error). ! * VC11 and VC12: _wstat() doesn't return an error for a symlink to a ! * directory, but it doesn't set S_IFDIR flag. ! * MinGW: Same as VC9. */ int n; BOOL is_symlink = FALSE; HANDLE hFind, h; *************** *** 587,592 **** --- 597,604 ---- fd = _open_osfhandle((OPEN_OH_ARGTYPE)h, _O_RDONLY); n = _fstat(fd, stp); + if ((n == 0) && (attr & FILE_ATTRIBUTE_DIRECTORY)) + stp->st_mode = (stp->st_mode & ~S_IFREG) | S_IFDIR; _close(fd); return n; } *** ../vim-7.4.1138/src/version.c 2016-01-19 17:47:19.778767151 +0100 --- src/version.c 2016-01-19 18:59:16.128404054 +0100 *************** *** 743,744 **** --- 743,746 ---- { /* Add new patch number below this line */ + /**/ + 1139, /**/ -- hundred-and-one symptoms of being an internet addict: 7. You finally do take that vacation, but only after buying a cellular modem and a laptop. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///