aboutsummaryrefslogtreecommitdiff
path: root/win32/process.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-12-06 15:16:49 +0000
committerRon Yorston <rmy@pobox.com>2018-12-06 15:16:49 +0000
commit9906faf2dff6fd9033cb711619528501cae11721 (patch)
treea85bb3ee78f5d58378f23842e0e762e879db23bc /win32/process.c
parentd257c7f2b6c44662c793d00d0b9286d6246b84a3 (diff)
downloadbusybox-w32-9906faf2dff6fd9033cb711619528501cae11721.tar.gz
busybox-w32-9906faf2dff6fd9033cb711619528501cae11721.tar.bz2
busybox-w32-9906faf2dff6fd9033cb711619528501cae11721.zip
win32: rework adding of extensions to filenames
Previously there was one function to handle adding extensions to executable filenames, add_win32_extension(). Refactor this into three functions: add_win32_extension() appends the suffix to the argument string in-place. The argument must be long enough to cope with this, as is the case in ash where path_advance() adds 4 bytes to each filename for just this reason. alloc_win32_extension() is equivalent to the old add_win32_extension(). It allocates a string to hold the new filename then calls the new add_win32_extension() function. The caller is responsible for managing the returned string. auto_win32_extension() calls alloc_win32_extension() and saves the resulting string using auto_string(). It's used where the new filename is consumed immediately or the actual value isn't needed. Rewrite code to use the most appropriate function. Also reorder some code in find_executable() and find_command().
Diffstat (limited to 'win32/process.c')
-rw-r--r--win32/process.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/win32/process.c b/win32/process.c
index e9b34b56d..b7f02e431 100644
--- a/win32/process.c
+++ b/win32/process.c
@@ -240,7 +240,7 @@ spawnveq(int mode, const char *path, char *const *argv, char *const *env)
240 p = strdup(new_argv[0]); 240 p = strdup(new_argv[0]);
241 } 241 }
242 else { 242 else {
243 p = add_win32_extension(new_argv[0]); 243 p = alloc_win32_extension(new_argv[0]);
244 } 244 }
245 245
246 if (p != NULL && has_bat_suffix(p)) { 246 if (p != NULL && has_bat_suffix(p)) {
@@ -307,7 +307,7 @@ mingw_spawn_interpreter(int mode, const char *prog, char *const *argv, char *con
307 new_argv[nopts+1] = (char *)prog; /* pass absolute path */ 307 new_argv[nopts+1] = (char *)prog; /* pass absolute path */
308 memcpy(new_argv+nopts+2, argv+1, sizeof(*argv)*argc); 308 memcpy(new_argv+nopts+2, argv+1, sizeof(*argv)*argc);
309 309
310 if ((fullpath=add_win32_extension(interp.path)) != NULL || 310 if ((fullpath=alloc_win32_extension(interp.path)) != NULL ||
311 file_is_executable(interp.path)) { 311 file_is_executable(interp.path)) {
312 new_argv[0] = fullpath ? fullpath : interp.path; 312 new_argv[0] = fullpath ? fullpath : interp.path;
313 ret = spawnveq(mode, new_argv[0], new_argv, envp); 313 ret = spawnveq(mode, new_argv[0], new_argv, envp);