Révision | 05942d8a1b618e1c850b67ad76374f8c59743df5 (tree) |
---|---|
l'heure | 2014-12-31 04:14:25 |
Auteur | Eli Zaretskii <eliz@gnu....> |
Commiter | Eli Zaretskii |
Fix executable indicator in file name completion on Windows.
* complete.c (stat_char) [_WIN32]: Don't use 'access' and X_OK on
Windows, they don't work. Instead, look at the file-name
extension to determine whether the file is executable.
@@ -1,3 +1,9 @@ | ||
1 | +2014-12-30 Eli Zaretskii <eliz@gnu.org> | |
2 | + | |
3 | + * complete.c (stat_char) [_WIN32]: Don't use 'access' and X_OK on | |
4 | + Windows, they don't work. Instead, look at the file-name | |
5 | + extension to determine whether the file is executable. | |
6 | + | |
1 | 7 | 2014-09-22 Chen Gang <gang.chen.5i5j@gmail.com> |
2 | 8 | |
3 | 9 | Pushed by Joel Brobecker <brobecker@adacore.com> |
@@ -598,8 +598,21 @@ stat_char (filename) | ||
598 | 598 | #endif |
599 | 599 | else if (S_ISREG (finfo.st_mode)) |
600 | 600 | { |
601 | +#if defined (_WIN32) && !defined (__CYGWIN__) | |
602 | + /* Windows 'access' doesn't support X_OK and on latest Windows | |
603 | + versions even invokes an invalid parameter exception. */ | |
604 | + char *ext = strrchr (filename, '.'); | |
605 | + | |
606 | + if (ext | |
607 | + && (_rl_stricmp (ext, ".exe") == 0 | |
608 | + || _rl_stricmp (ext, ".cmd") == 0 | |
609 | + || _rl_stricmp (ext, ".bat") == 0 | |
610 | + || _rl_stricmp (ext, ".com") == 0)) | |
611 | + character = '*'; | |
612 | +#else | |
601 | 613 | if (access (filename, X_OK) == 0) |
602 | 614 | character = '*'; |
615 | +#endif | |
603 | 616 | } |
604 | 617 | return (character); |
605 | 618 | } |