From 64ecd10486934c12336dac84c67a1939dce0e096 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 23 Aug 2020 10:16:12 +0100 Subject: win32: code shrink Unix-style path handling Replace auto_add_system_drive() with alloc_system_drive() which leaves space for a possible filename extension. This makes it possible to drop alloc_win32_extension() and auto_win32_extension(). Saves 144 bytes. --- shell/ash.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index abefba074..7967872f7 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -8784,15 +8784,19 @@ static void shellexec(char *prog, char **argv, const char *path, int idx) */ goto try_PATH; } + e = errno; #if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE - if (strcmp(oldprog, prog) != 0 && unix_path(oldprog)) { - if ((applet_no = find_applet_by_name(bb_basename(oldprog))) >= 0) - tryexec(applet_no, bb_basename(oldprog), argv, envp); - else - errno = ENOENT; + if (unix_path(oldprog)) { + const char *name = bb_basename(oldprog); + if ((applet_no = find_applet_by_name(name)) >= 0) { + tryexec(applet_no, name, argv, envp); + e = errno; + } + else { + e = ENOENT; + } } #endif - e = errno; } else { try_PATH: e = ENOENT; @@ -14318,16 +14322,13 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) #else /* ENABLE_PLATFORM_MINGW32 */ /* If name contains a slash or drive prefix, don't use PATH or hash table */ if (has_path(name)) { -# if ENABLE_FEATURE_SH_STANDALONE - char *oldname = name; -# endif - name = stack_add_system_drive(name); + fullname = stack_add_system_drive(name); entry->u.index = -1; if (act & DO_ABS) { - if (!add_win32_extension(name) && stat(name, &statb) < 0) { + if (!add_win32_extension(fullname) && stat(fullname, &statb) < 0) { # if ENABLE_FEATURE_SH_STANDALONE - if (unix_path(oldname) && - find_applet_by_name(bb_basename(oldname)) >= 0) { + if (unix_path(name) && + find_applet_by_name(bb_basename(name)) >= 0) { entry->cmdtype = CMDNORMAL; entry->u.index = INT_MIN; return; -- cgit v1.2.3-55-g6feb