xolox/vim-misc — pull request #3 by inkarkat (2013-05-23 14:34:38+00:00)
Title: FIX: path#which() does not handle already existing Windows file extensio...

I found this problem while checking out your easytags _async_ branch. My `v:progname` yields `gvim.exe`, which the plugin translated into the empty string.

When I invoke `xolox#misc#path#which('gvim.exe')` on Windows, nothing is returned. The problem is that all file extensions in $PATHEXT are appended, but it is not checked whether the passed program as-is is executable. Let's do that last when no extension yields a match; this avoids that BOTH .../gvim and .../gvim.exe are returned.

Additionally, the iteration logic is wrong. Windows does not check all PATH components for .BAT files, then check all for .EXE etc. Instead, executables in an earlier component of PATH are preferred, regardless of the order of the file extension in PATHEXT. Therefore, swap the inner and outer loop. It's also more efficient, because xolox#misc#path#absolute(directory) is only done once for each component.