diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-09-14 11:02:01 +1000 |
---|---|---|
committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-09-14 11:06:23 +1000 |
commit | b3129dcb497732f827c56666617b0744bcab1315 (patch) | |
tree | 468e197e3adbce7a6fe55fc561f913f8fcc05a52 | |
parent | a102166268ed566d9bcd9884396add2aef5b9dff (diff) | |
download | busybox-w32-b3129dcb497732f827c56666617b0744bcab1315.tar.gz busybox-w32-b3129dcb497732f827c56666617b0744bcab1315.tar.bz2 busybox-w32-b3129dcb497732f827c56666617b0744bcab1315.zip |
win32: test: support .com executables
-rw-r--r-- | coreutils/test.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/coreutils/test.c b/coreutils/test.c index b523671df..3115ce6e7 100644 --- a/coreutils/test.c +++ b/coreutils/test.c | |||
@@ -602,17 +602,22 @@ static int filstat(char *nm, enum token mode) | |||
602 | #if ENABLE_PLATFORM_MINGW32 | 602 | #if ENABLE_PLATFORM_MINGW32 |
603 | if (mode == FILEX) { | 603 | if (mode == FILEX) { |
604 | int len = strlen(nm), ret; | 604 | int len = strlen(nm), ret; |
605 | char *exepath; | 605 | if (len >= 4 && |
606 | if (len >= 4 && !strcmp(nm+len-4,".exe")) | 606 | (!strcmp(nm+len-4,".exe") || |
607 | exepath = nm; | 607 | !strcmp(nm+len-4,".com"))) |
608 | ret = stat(nm, &s); | ||
608 | else { | 609 | else { |
610 | char *exepath; | ||
609 | exepath = malloc(len+5); | 611 | exepath = malloc(len+5); |
610 | memcpy(exepath, nm, len); | 612 | memcpy(exepath, nm, len); |
611 | memcpy(exepath+len, ".exe", 5); | 613 | memcpy(exepath+len, ".exe", 5); |
612 | } | 614 | ret = stat(exepath, &s); |
613 | ret = stat(exepath, &s); | 615 | if (ret < 0) { |
614 | if (exepath != nm) | 616 | memcpy(exepath+len, ".exe", 5); |
617 | ret = stat(exepath, &s); | ||
618 | } | ||
615 | free(exepath); | 619 | free(exepath); |
620 | } | ||
616 | return ret >= 0; | 621 | return ret >= 0; |
617 | } | 622 | } |
618 | #endif | 623 | #endif |