diff options
Diffstat (limited to 'coreutils/test.c')
-rw-r--r-- | coreutils/test.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/coreutils/test.c b/coreutils/test.c index ccfa923da..80f540c22 100644 --- a/coreutils/test.c +++ b/coreutils/test.c | |||
@@ -648,24 +648,16 @@ static int filstat(char *nm, enum token mode) | |||
648 | #undef W_OK | 648 | #undef W_OK |
649 | #define W_OK S_IWRITE | 649 | #define W_OK S_IWRITE |
650 | if (mode == FILEX) { | 650 | if (mode == FILEX) { |
651 | int len = strlen(nm), ret; | 651 | char *p; |
652 | if (len >= 4 && | 652 | |
653 | (!strcmp(nm+len-4,".exe") || | 653 | if (execable_file(nm)) { |
654 | !strcmp(nm+len-4,".com"))) | 654 | return 1; |
655 | ret = stat(nm, &s); | ||
656 | else { | ||
657 | char *exepath; | ||
658 | exepath = malloc(len+5); | ||
659 | memcpy(exepath, nm, len); | ||
660 | memcpy(exepath+len, ".exe", 5); | ||
661 | ret = stat(exepath, &s); | ||
662 | if (ret < 0) { | ||
663 | memcpy(exepath+len, ".exe", 5); | ||
664 | ret = stat(exepath, &s); | ||
665 | } | ||
666 | free(exepath); | ||
667 | } | 655 | } |
668 | return ret >= 0; | 656 | else if ((p=win32_execable_file(nm))) { |
657 | free(p); | ||
658 | return 1; | ||
659 | } | ||
660 | return 0; | ||
669 | } | 661 | } |
670 | #endif | 662 | #endif |
671 | 663 | ||