diff options
Diffstat (limited to 'coreutils/test.c')
-rw-r--r-- | coreutils/test.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/coreutils/test.c b/coreutils/test.c index 5864c7f32..3115ce6e7 100644 --- a/coreutils/test.c +++ b/coreutils/test.c | |||
@@ -599,6 +599,29 @@ static int filstat(char *nm, enum token mode) | |||
599 | return 0; | 599 | return 0; |
600 | } | 600 | } |
601 | 601 | ||
602 | #if ENABLE_PLATFORM_MINGW32 | ||
603 | if (mode == FILEX) { | ||
604 | int len = strlen(nm), ret; | ||
605 | if (len >= 4 && | ||
606 | (!strcmp(nm+len-4,".exe") || | ||
607 | !strcmp(nm+len-4,".com"))) | ||
608 | ret = stat(nm, &s); | ||
609 | else { | ||
610 | char *exepath; | ||
611 | exepath = malloc(len+5); | ||
612 | memcpy(exepath, nm, len); | ||
613 | memcpy(exepath+len, ".exe", 5); | ||
614 | ret = stat(exepath, &s); | ||
615 | if (ret < 0) { | ||
616 | memcpy(exepath+len, ".exe", 5); | ||
617 | ret = stat(exepath, &s); | ||
618 | } | ||
619 | free(exepath); | ||
620 | } | ||
621 | return ret >= 0; | ||
622 | } | ||
623 | #endif | ||
624 | |||
602 | if (stat(nm, &s) != 0) | 625 | if (stat(nm, &s) != 0) |
603 | return 0; | 626 | return 0; |
604 | if (mode == FILEXIST) | 627 | if (mode == FILEXIST) |