diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 45 |
1 files changed, 12 insertions, 33 deletions
diff --git a/shell/ash.c b/shell/ash.c index 8497538b1..13200da0c 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -2158,17 +2158,13 @@ maybe_single_quote(const char *s) | |||
2158 | } | 2158 | } |
2159 | 2159 | ||
2160 | #if ENABLE_PLATFORM_MINGW32 | 2160 | #if ENABLE_PLATFORM_MINGW32 |
2161 | /* | 2161 | /* Copy path to a string on the stack long enough to allow a file extension |
2162 | * Place 'path' in a string on the stack, adding the system drive prefix | 2162 | * to be added. */ |
2163 | * if necessary and leaving room for an optional extension. | ||
2164 | */ | ||
2165 | static char * | 2163 | static char * |
2166 | stack_add_system_drive(const char *path) | 2164 | stack_add_ext_space(const char *path) |
2167 | { | 2165 | { |
2168 | const char *sd = need_system_drive(path); | 2166 | char *p = growstackto(strlen(path) + 5); |
2169 | char *p = growstackto(strlen(path) + 5 + (sd ? strlen(sd) : 0)); | 2167 | strcpy(p, path); |
2170 | |||
2171 | strcpy(stpcpy(p, sd ?: ""), path); | ||
2172 | return p; | 2168 | return p; |
2173 | } | 2169 | } |
2174 | #endif | 2170 | #endif |
@@ -2947,10 +2943,6 @@ padvance_magic(const char **path, const char *name, int magic) | |||
2947 | const char *start; | 2943 | const char *start; |
2948 | size_t qlen; | 2944 | size_t qlen; |
2949 | size_t len; | 2945 | size_t len; |
2950 | #if ENABLE_PLATFORM_MINGW32 | ||
2951 | size_t sdlen = 0; | ||
2952 | const char *sd; | ||
2953 | #endif | ||
2954 | 2946 | ||
2955 | if (*path == NULL) | 2947 | if (*path == NULL) |
2956 | return -1; | 2948 | return -1; |
@@ -2982,20 +2974,11 @@ padvance_magic(const char **path, const char *name, int magic) | |||
2982 | *path = *p == PATH_SEP ? p + 1 : NULL; | 2974 | *path = *p == PATH_SEP ? p + 1 : NULL; |
2983 | 2975 | ||
2984 | /* "2" is for '/' and '\0' */ | 2976 | /* "2" is for '/' and '\0' */ |
2985 | qlen = len + strlen(name) + 2; | 2977 | /* reserve space for suffix on WIN32 */ |
2986 | #if ENABLE_PLATFORM_MINGW32 | 2978 | qlen = len + strlen(name) + 2 IF_PLATFORM_MINGW32(+ 4); |
2987 | /* reserve space for system drive prefix and extension */ | ||
2988 | sd = need_system_drive(start); | ||
2989 | if (sd != NULL) | ||
2990 | sdlen = strlen(sd); | ||
2991 | qlen += 4 + sdlen; | ||
2992 | #endif | ||
2993 | q = growstackto(qlen); | 2979 | q = growstackto(qlen); |
2994 | 2980 | ||
2995 | if (len) { | 2981 | if (len) { |
2996 | #if ENABLE_PLATFORM_MINGW32 | ||
2997 | q = mempcpy(q, sd, sdlen); | ||
2998 | #endif | ||
2999 | q = mempcpy(q, start, len); | 2982 | q = mempcpy(q, start, len); |
3000 | #if ENABLE_PLATFORM_MINGW32 | 2983 | #if ENABLE_PLATFORM_MINGW32 |
3001 | if (q[-1] != '/' && q[-1] != '\\') | 2984 | if (q[-1] != '/' && q[-1] != '\\') |
@@ -9058,10 +9041,6 @@ static void shellexec(char *prog, char **argv, const char *path, int idx) | |||
9058 | || (applet_no = find_applet_by_name(prog)) >= 0 | 9041 | || (applet_no = find_applet_by_name(prog)) >= 0 |
9059 | #endif | 9042 | #endif |
9060 | ) { | 9043 | ) { |
9061 | #if ENABLE_PLATFORM_MINGW32 | ||
9062 | char *oldprog = prog; | ||
9063 | prog = stack_add_system_drive(prog); | ||
9064 | #endif | ||
9065 | tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) prog, argv, envp); | 9044 | tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) prog, argv, envp); |
9066 | if (applet_no >= 0) { | 9045 | if (applet_no >= 0) { |
9067 | /* We tried execing ourself, but it didn't work. | 9046 | /* We tried execing ourself, but it didn't work. |
@@ -9072,15 +9051,15 @@ static void shellexec(char *prog, char **argv, const char *path, int idx) | |||
9072 | } | 9051 | } |
9073 | e = errno; | 9052 | e = errno; |
9074 | #if ENABLE_PLATFORM_MINGW32 | 9053 | #if ENABLE_PLATFORM_MINGW32 |
9075 | if (unix_path(oldprog) && !find_builtin(bb_basename(oldprog))) { | 9054 | if (unix_path(prog) && !find_builtin(bb_basename(prog))) { |
9076 | # if ENABLE_FEATURE_SH_STANDALONE | 9055 | # if ENABLE_FEATURE_SH_STANDALONE |
9077 | const char *name = bb_basename(oldprog); | 9056 | const char *name = bb_basename(prog); |
9078 | if ((applet_no = find_applet_by_name(name)) >= 0) { | 9057 | if ((applet_no = find_applet_by_name(name)) >= 0) { |
9079 | tryexec(applet_no, name, argv, envp); | 9058 | tryexec(applet_no, name, argv, envp); |
9080 | e = errno; | 9059 | e = errno; |
9081 | } | 9060 | } |
9082 | # endif | 9061 | # endif |
9083 | argv[0] = (char *)bb_basename(oldprog); | 9062 | argv[0] = (char *)bb_basename(prog); |
9084 | goto try_PATH; | 9063 | goto try_PATH; |
9085 | } | 9064 | } |
9086 | #endif | 9065 | #endif |
@@ -9523,7 +9502,7 @@ describe_command(char *command, const char *path, int describe_command_verbose) | |||
9523 | #endif | 9502 | #endif |
9524 | if (j < 0) { | 9503 | if (j < 0) { |
9525 | #if ENABLE_PLATFORM_MINGW32 | 9504 | #if ENABLE_PLATFORM_MINGW32 |
9526 | p = stack_add_system_drive(command); | 9505 | p = stack_add_ext_space(command); |
9527 | #else | 9506 | #else |
9528 | p = command; | 9507 | p = command; |
9529 | #endif | 9508 | #endif |
@@ -14720,7 +14699,7 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) | |||
14720 | if (has_path(name)) { | 14699 | if (has_path(name)) { |
14721 | entry->u.index = -1; | 14700 | entry->u.index = -1; |
14722 | entry->cmdtype = CMDNORMAL; | 14701 | entry->cmdtype = CMDNORMAL; |
14723 | fullname = stack_add_system_drive(name); | 14702 | fullname = stack_add_ext_space(name); |
14724 | if (add_win32_extension(fullname) || file_is_executable(fullname)) { | 14703 | if (add_win32_extension(fullname) || file_is_executable(fullname)) { |
14725 | return; | 14704 | return; |
14726 | } else if (unix_path(name) && !find_builtin(bb_basename(name))) { | 14705 | } else if (unix_path(name) && !find_builtin(bb_basename(name))) { |