aboutsummaryrefslogtreecommitdiff
path: root/libbb/executable.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-03-16 10:47:09 +0000
committerRon Yorston <rmy@pobox.com>2023-03-16 10:47:09 +0000
commit184edf9bd672bc93856157098d528eab48948ba9 (patch)
tree183531c00207b293de9a609384e0ef9ff7dbfac5 /libbb/executable.c
parent385decd6bf62c116565ece1e0992ff7a79d48474 (diff)
downloadbusybox-w32-184edf9bd672bc93856157098d528eab48948ba9.tar.gz
busybox-w32-184edf9bd672bc93856157098d528eab48948ba9.tar.bz2
busybox-w32-184edf9bd672bc93856157098d528eab48948ba9.zip
win32: code shrink detection of executables
Add a function, file_is_win32_exe(), to detect if a path refers to an executable. It tries adding extensions if necessary. Use this in a number of places to replace common code of the form path = alloc_ext_space(cmd); if (add_win32_extension(path) || file_is_executable(path)) Saves 32-48 bytes.
Diffstat (limited to 'libbb/executable.c')
-rw-r--r--libbb/executable.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libbb/executable.c b/libbb/executable.c
index 770aedc0c..606bec986 100644
--- a/libbb/executable.c
+++ b/libbb/executable.c
@@ -57,10 +57,12 @@ char* FAST_FUNC find_executable(const char *filename, char **PATHp)
57 ); 57 );
58#if ENABLE_PLATFORM_MINGW32 58#if ENABLE_PLATFORM_MINGW32
59 { 59 {
60 char *w = alloc_ext_space(p); 60 char *w = file_is_win32_exe(p);
61 ex = add_win32_extension(w) || file_is_executable(w); 61 ex = w != NULL;
62 free(p); 62 if (ex) {
63 p = w; 63 free(p);
64 p = w;
65 }
64 } 66 }
65#else 67#else
66 ex = file_is_executable(p); 68 ex = file_is_executable(p);