[vim/vim] Implement lstat() for Windows (PR #15014)

27 views
Skip to first unread message

LemonBoy

unread,
Jun 15, 2024, 12:54:03 PM (11 days ago) Jun 15
to vim/vim, Subscribed

lstat() differs from stat() in how it handles symbolic links, the former
doesn't resolve the symlink while the latter does so.

Implement a simple yet effective fallback using Win32 APIs.

Fixes #14933


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/15014

Commit Summary

File Changes

(3 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15014@github.com>

LemonBoy

unread,
Jun 15, 2024, 1:05:11 PM (11 days ago) Jun 15
to vim/vim, Push

@LemonBoy pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15014/before/61aaf315de8c58c326a1c78f2f5347634a815a98/after/f481705013f9978c6f03fc40738d67c75e95d793@github.com>

LemonBoy

unread,
Jun 15, 2024, 3:31:09 PM (11 days ago) Jun 15
to vim/vim, Push

@LemonBoy pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15014/before/f481705013f9978c6f03fc40738d67c75e95d793/after/84eca7d3f2f65a913b27effd77c6fe481a22f37a@github.com>

Christian Brabandt

unread,
Jun 16, 2024, 2:39:55 AM (10 days ago) Jun 16
to vim/vim, Subscribed

thank you! can we get a test please?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15014/c2171090853@github.com>

LemonBoy

unread,
Jun 17, 2024, 5:25:38 AM (9 days ago) Jun 17
to vim/vim, Push

@LemonBoy pushed 2 commits.

  • 369cb80 Fix glob expansion on Windows
  • 19cfeae Add test for glob() alllinks parameter

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15014/before/84eca7d3f2f65a913b27effd77c6fe481a22f37a/after/19cfeaeb0bf703d7f2375d4f24994b83fe0eb5f0@github.com>

K.Takata

unread,
Jun 17, 2024, 5:52:40 AM (9 days ago) Jun 17
to vim/vim, Subscribed

@k-takata commented on this pull request.


In src/testdir/test_functions.vim:

> +    silent !ln -s XglobBad DoesNotExist
+    silent !ln -s XglobOk Xglob1

It seems reversed:

⬇️ Suggested change
-    silent !ln -s XglobBad DoesNotExist
-    silent !ln -s XglobOk Xglob1
+    silent !ln -s DoesNotExist XglobBad
+    silent !ln -s Xglob1 XglobOk


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15014/review/2122448693@github.com>

LemonBoy

unread,
Jun 17, 2024, 6:20:46 AM (9 days ago) Jun 17
to vim/vim, Push

@LemonBoy pushed 1 commit.

  • 23c0b2f Fix argument order in ln invocation

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15014/before/19cfeaeb0bf703d7f2375d4f24994b83fe0eb5f0/after/23c0b2f24ebf515781835af331cd820cea376b1f@github.com>

K.Takata

unread,
Jun 17, 2024, 6:50:14 AM (9 days ago) Jun 17
to vim/vim, Subscribed

MinGW is now failing.
Maybe we should not fall back to _wstat() in wstat_symlink_aware()?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15014/c2173064964@github.com>

LemonBoy

unread,
Jun 17, 2024, 1:47:32 PM (9 days ago) Jun 17
to vim/vim, Subscribed

Hmm, it's just MinGW being MinGW. ln -s performs a full copy (!!!) unless you specify some flag and enable the Windows' developer mode. What shall we do here? Perhaps skipping the test on MinGW is an option here.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15014/c2173984391@github.com>

Christian Brabandt

unread,
Jun 17, 2024, 2:04:56 PM (9 days ago) Jun 17
to vim/vim, Subscribed

If that is the case, I am fine with skipping. But I don't know how to detect that Vim is running in a Mingw/Msys environment.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15014/c2174011814@github.com>

Gary Johnson

unread,
Jun 17, 2024, 3:37:03 PM (9 days ago) Jun 17
to reply+ACY5DGCCCNRBZB4QJO...@reply.github.com, vim...@googlegroups.com
On 2024-06-17, Christian Brabandt wrote:
> If that is the case, I am fine with skipping. But I don't know how to detect
> that Vim is running in a Mingw/Msys environment.

My MINGW64 installation has a couple of environment variables that
you could test.

MSYSTEM=MINGW64
OSTYPE=msys

Regards,
Gary

vim-dev ML

unread,
Jun 17, 2024, 3:37:30 PM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Your activity


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15014/c2174275096@github.com>

K.Takata

unread,
Jun 17, 2024, 4:48:17 PM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Comment

Try this:
k-takata@ce07a7a


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15014/c2174395589@github.com>

LemonBoy

unread,
Jun 17, 2024, 4:54:58 PM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Push

@LemonBoy pushed 1 commit.

  • 5fe56ac Skip symlink test on MinGW/Msys/Cygwin

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15014/before/23c0b2f24ebf515781835af331cd820cea376b1f/after/5fe56aca762e47da5c558721cfab3e62e409de40@github.com>

K.Takata

unread,
Jun 17, 2024, 8:43:10 PM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Comment

Moreover, how about merging mswin_lstat() and wstat_symlink_aware() into one function?
k-takata@b48ce1c
No need to skip the symlink test on MinGW.
Here are the results: https://github.com/k-takata/vim/actions/runs/9556704996

ln -s performs a full copy (!!!)

It is not the reason why it failed on MinGW. has("win32") is true on MinGW, so the symlinks are created by the mklink command.
If we want to test the MSYS version of Vim, we need to care about the ln -s issue, but currently, we don't have MSYS tests.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15014/c2174693999@github.com>

K.Takata

unread,
Jun 17, 2024, 9:09:22 PM (9 days ago) Jun 17
to vim/vim, vim-dev ML, Comment

To skip the test on MSYS, the check should be like this:

  if has('win32unix') && executable('uname') && system('uname -s') =~ '^MSYS'
    throw 'Skipped: does not work on Msys'
  endif

Note that has('win32unix') is used instead of has('win32') because MSYS is a variant of Cygwin.
has('win32') returns 0 on Cygwin/MSYS.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15014/c2174716944@github.com>

LemonBoy

unread,
Jun 18, 2024, 3:54:58 AM (8 days ago) Jun 18
to vim/vim, vim-dev ML, Push

@LemonBoy pushed 1 commit.

  • 520e182 Unify the stat() and lstat() impl for Windows

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15014/before/5fe56aca762e47da5c558721cfab3e62e409de40/after/520e182eee201750f37de7e42cf3394e75f65863@github.com>

LemonBoy

unread,
Jun 18, 2024, 3:59:26 AM (8 days ago) Jun 18
to vim/vim, vim-dev ML, Comment

Moreover, how about merging mswin_lstat() and wstat_symlink_aware() into one function?

Good idea, merged!

It is not the reason why it failed on MinGW. has("win32") is true on MinGW, so the symlinks are created by the mklink command.
If we want to test the MSYS version of Vim, we need to care about the ln -s issue, but currently, we don't have MSYS tests.

Oh well, it seems that every Unix layer tries do do its own thing with symlinks. Let's forget about MSYS for the time being then.

To skip the test on MSYS, the check should be like this:

On my MSYS-compiled version (using Make_cyg_ming.mak) the 'win32unix' is not defined.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15014/c2175450166@github.com>

K.Takata

unread,
Jun 18, 2024, 5:15:50 AM (8 days ago) Jun 18
to vim/vim, vim-dev ML, Comment

On my MSYS-compiled version (using Make_cyg_ming.mak) the 'win32unix' is not defined.

It is just a normal Win32 (or Win64) version of Vim. It should work as the same as MSVC-compiled version. (No need to care about MSYS-style symlinks.)
The MSYS version I meant was which was compiled by the MSYS version of GCC (/usr/bin/gcc) using src/Makefile.

Let's forget about MSYS for the time being then.

👍


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: <vim/vim/pull/15014/c2175608347@github.com>

Christian Brabandt

unread,
Jun 18, 2024, 2:37:56 PM (8 days ago) Jun 18
to vim/vim, vim-dev ML, Comment

thanks, let me include it then!


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15014/c2176729492@github.com>

Christian Brabandt

unread,
Jun 18, 2024, 2:46:55 PM (8 days ago) Jun 18
to vim/vim, vim-dev ML, Comment

Closed #15014 via 23c5ebe.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/15014/issue_event/13205193056@github.com>

Reply all
Reply to author
Forward
0 new messages