aboutsummaryrefslogtreecommitdiff
path: root/libbb/appletlib.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-06-05 11:10:22 +0100
committerRon Yorston <rmy@pobox.com>2023-06-05 11:10:22 +0100
commit374b4e872a8981ec01707812d8822c9fb9a52d20 (patch)
treebab4ea4d9726d5e3ca98cefb1f6db873af8a4876 /libbb/appletlib.c
parent0b6aed138649cb843cbbdfe2ca5ff5e56f3a0825 (diff)
downloadbusybox-w32-374b4e872a8981ec01707812d8822c9fb9a52d20.tar.gz
busybox-w32-374b4e872a8981ec01707812d8822c9fb9a52d20.tar.bz2
busybox-w32-374b4e872a8981ec01707812d8822c9fb9a52d20.zip
win32: code shrink applet look-up
- Remove find_preferred_applet_by_name(). Instead add a reference to is_applet_preferred() in find_applet_by_name(). - Remove the global variable ash_path. Use a static instead, accessed by calling get_ash_path(). - Mark ash_applet_by_name() as NOINLINE. Saves 64-96 bytes. (GitHub issue #329)
Diffstat (limited to 'libbb/appletlib.c')
-rw-r--r--libbb/appletlib.c22
1 files changed, 2 insertions, 20 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 10268b982..a378846b9 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -76,13 +76,6 @@ static inline int *get_perrno(void) { return &errno; }
76static const char packed_scripts[] ALIGN1 = { PACKED_SCRIPTS }; 76static const char packed_scripts[] ALIGN1 = { PACKED_SCRIPTS };
77#endif 77#endif
78 78
79#if defined(find_applet_by_name)
80# undef find_applet_by_name
81#endif
82#if defined(is_applet_preferred)
83# undef is_applet_preferred
84#endif
85
86/* "Do not compress usage text if uncompressed text is small 79/* "Do not compress usage text if uncompressed text is small
87 * and we don't include bunzip2 code for other reasons" 80 * and we don't include bunzip2 code for other reasons"
88 * 81 *
@@ -245,7 +238,7 @@ int FAST_FUNC find_applet_by_name(const char *name)
245 for (j = 0; *p == name[j]; ++j) { 238 for (j = 0; *p == name[j]; ++j) {
246 if (*p++ == '\0') { 239 if (*p++ == '\0') {
247 //bb_error_msg("found:'%s' i:%u", name, i); 240 //bb_error_msg("found:'%s' i:%u", name, i);
248 return i; /* yes */ 241 return is_applet_preferred(name) ? i : -1; /* yes */
249 } 242 }
250 } 243 }
251 /* No. Have we gone too far, alphabetically? */ 244 /* No. Have we gone too far, alphabetically? */
@@ -263,14 +256,9 @@ int FAST_FUNC find_applet_by_name(const char *name)
263 256
264#if ENABLE_PLATFORM_MINGW32 && NUM_APPLETS > 1 && \ 257#if ENABLE_PLATFORM_MINGW32 && NUM_APPLETS > 1 && \
265 (ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE) 258 (ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE)
266# if ENABLE_ASH
267const char *ash_path = NULL;
268# else
269# define ash_path NULL
270# endif
271
272static int external_exists(const char *name) 259static int external_exists(const char *name)
273{ 260{
261 const char *ash_path = get_ash_path();
274 char *path = ash_path ? auto_string(xstrdup(ash_path)) : getenv("PATH"); 262 char *path = ash_path ? auto_string(xstrdup(ash_path)) : getenv("PATH");
275 char *ret = find_executable(name, &path); 263 char *ret = find_executable(name, &path);
276 free(ret); 264 free(ret);
@@ -314,12 +302,6 @@ int FAST_FUNC is_applet_preferred(const char *name)
314 } 302 }
315 return TRUE; 303 return TRUE;
316} 304}
317
318int FAST_FUNC find_preferred_applet_by_name(const char *name)
319{
320 int applet_no = find_applet_by_name(name);
321 return applet_no >= 0 && is_applet_preferred(name) ? applet_no : -1;
322}
323#endif 305#endif
324 306
325 307