aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2020-08-23 10:16:12 +0100
committerRon Yorston <rmy@pobox.com>2020-08-23 10:16:12 +0100
commit64ecd10486934c12336dac84c67a1939dce0e096 (patch)
tree73e8bc6b07176b84295fd07f19828292a240f693 /shell
parentd6b557547551dd80a389f361a995a97ef5930a63 (diff)
downloadbusybox-w32-64ecd10486934c12336dac84c67a1939dce0e096.tar.gz
busybox-w32-64ecd10486934c12336dac84c67a1939dce0e096.tar.bz2
busybox-w32-64ecd10486934c12336dac84c67a1939dce0e096.zip
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.
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c27
1 files changed, 14 insertions, 13 deletions
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)
8784 */ 8784 */
8785 goto try_PATH; 8785 goto try_PATH;
8786 } 8786 }
8787 e = errno;
8787#if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE 8788#if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE
8788 if (strcmp(oldprog, prog) != 0 && unix_path(oldprog)) { 8789 if (unix_path(oldprog)) {
8789 if ((applet_no = find_applet_by_name(bb_basename(oldprog))) >= 0) 8790 const char *name = bb_basename(oldprog);
8790 tryexec(applet_no, bb_basename(oldprog), argv, envp); 8791 if ((applet_no = find_applet_by_name(name)) >= 0) {
8791 else 8792 tryexec(applet_no, name, argv, envp);
8792 errno = ENOENT; 8793 e = errno;
8794 }
8795 else {
8796 e = ENOENT;
8797 }
8793 } 8798 }
8794#endif 8799#endif
8795 e = errno;
8796 } else { 8800 } else {
8797 try_PATH: 8801 try_PATH:
8798 e = ENOENT; 8802 e = ENOENT;
@@ -14318,16 +14322,13 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path)
14318#else /* ENABLE_PLATFORM_MINGW32 */ 14322#else /* ENABLE_PLATFORM_MINGW32 */
14319 /* If name contains a slash or drive prefix, don't use PATH or hash table */ 14323 /* If name contains a slash or drive prefix, don't use PATH or hash table */
14320 if (has_path(name)) { 14324 if (has_path(name)) {
14321# if ENABLE_FEATURE_SH_STANDALONE 14325 fullname = stack_add_system_drive(name);
14322 char *oldname = name;
14323# endif
14324 name = stack_add_system_drive(name);
14325 entry->u.index = -1; 14326 entry->u.index = -1;
14326 if (act & DO_ABS) { 14327 if (act & DO_ABS) {
14327 if (!add_win32_extension(name) && stat(name, &statb) < 0) { 14328 if (!add_win32_extension(fullname) && stat(fullname, &statb) < 0) {
14328# if ENABLE_FEATURE_SH_STANDALONE 14329# if ENABLE_FEATURE_SH_STANDALONE
14329 if (unix_path(oldname) && 14330 if (unix_path(name) &&
14330 find_applet_by_name(bb_basename(oldname)) >= 0) { 14331 find_applet_by_name(bb_basename(name)) >= 0) {
14331 entry->cmdtype = CMDNORMAL; 14332 entry->cmdtype = CMDNORMAL;
14332 entry->u.index = INT_MIN; 14333 entry->u.index = INT_MIN;
14333 return; 14334 return;