From 184edf9bd672bc93856157098d528eab48948ba9 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 16 Mar 2023 10:47:09 +0000 Subject: 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. --- libbb/executable.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'libbb/executable.c') 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) ); #if ENABLE_PLATFORM_MINGW32 { - char *w = alloc_ext_space(p); - ex = add_win32_extension(w) || file_is_executable(w); - free(p); - p = w; + char *w = file_is_win32_exe(p); + ex = w != NULL; + if (ex) { + free(p); + p = w; + } } #else ex = file_is_executable(p); -- cgit v1.2.3-55-g6feb