aboutsummaryrefslogtreecommitdiff
path: root/libbb
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 /libbb
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 'libbb')
-rw-r--r--libbb/execable.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/libbb/execable.c b/libbb/execable.c
index c2a7bf0ca..ae61a8800 100644
--- a/libbb/execable.c
+++ b/libbb/execable.c
@@ -35,6 +35,9 @@ int FAST_FUNC execable_file(const char *name)
35char* FAST_FUNC find_execable(const char *filename, char **PATHp) 35char* FAST_FUNC find_execable(const char *filename, char **PATHp)
36{ 36{
37 char *p, *n; 37 char *p, *n;
38#if ENABLE_PLATFORM_MINGW32
39 char *w;
40#endif
38 41
39 p = *PATHp; 42 p = *PATHp;
40 while (p) { 43 while (p) {
@@ -47,29 +50,13 @@ char* FAST_FUNC find_execable(const char *filename, char **PATHp)
47 *PATHp = n; 50 *PATHp = n;
48 return p; 51 return p;
49 } 52 }
50 if (ENABLE_PLATFORM_MINGW32) { 53#if ENABLE_PLATFORM_MINGW32
51 int len = strlen(p); 54 else if ((w=win32_execable_file(p))) {
52 if (len > 4 && 55 *PATHp = n;
53 (!strcasecmp(p+len-4, ".exe") || 56 free(p);
54 !strcasecmp(p+len-4, ".com"))) 57 return w;
55 ; /* nothing, already tested by execable_file() */
56 else {
57 char *np = xmalloc(len+4+1);
58 memcpy(np, p, len);
59 memcpy(np+len, ".exe", 5);
60 if (execable_file(np)) {
61 *PATHp = n;
62 free(p);
63 return np;
64 }
65 memcpy(np+len, ".com", 5);
66 if (execable_file(np)) {
67 *PATHp = n;
68 free(p);
69 return np;
70 }
71 }
72 } 58 }
59#endif
73 free(p); 60 free(p);
74 } 61 }
75 p = n; 62 p = n;