aboutsummaryrefslogtreecommitdiff
path: root/coreutils/test.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-05-09 15:16:44 +0100
committerRon Yorston <rmy@pobox.com>2012-05-09 15:16:44 +0100
commit4066aff5e481941585c5958460c39a1b1399ce88 (patch)
tree87f3996a592298e744faa6b17b0af17c3786510a /coreutils/test.c
parentf2459f232790aab0434d1cc6471ea62bc193e636 (diff)
downloadbusybox-w32-4066aff5e481941585c5958460c39a1b1399ce88.tar.gz
busybox-w32-4066aff5e481941585c5958460c39a1b1399ce88.tar.bz2
busybox-w32-4066aff5e481941585c5958460c39a1b1399ce88.zip
Use win32_execable_file() in test, which and execable.c
Diffstat (limited to 'coreutils/test.c')
-rw-r--r--coreutils/test.c26
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