diff options
author | Ron Yorston <rmy@pobox.com> | 2022-10-26 11:47:42 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2022-10-26 11:47:42 +0100 |
commit | d71cb67ff91762ae78e87440b87d7c9a160b2937 (patch) | |
tree | e378f71776199ff4fe44cb3bc020a8f43278bd2b /win32 | |
parent | 0b5bd6e1436c38a74c5294535d5f4d7a7cf79d54 (diff) | |
download | busybox-w32-d71cb67ff91762ae78e87440b87d7c9a160b2937.tar.gz busybox-w32-d71cb67ff91762ae78e87440b87d7c9a160b2937.tar.bz2 busybox-w32-d71cb67ff91762ae78e87440b87d7c9a160b2937.zip |
win32: revert special treatment of Unix-style absolute paths
Commit 605972390 (win32: handle Unix-style absolute paths for
executables) added special treatment of paths for executables
starting with a slash. Such paths are absolute on Unix but are
relative to the current drive on Windows. On reflection this
commit did more than necessary. Later commits provided special
treatment only for paths starting with locations traditionally
used to contain binaries on Unix. This is probably sufficient.
Problems introduced by commit 605972390 include:
- If the current drive isn't the system drive tab completion of a
command starting with a slash confusingly references the system
drive.
- Building busybox-w32 with w64devkit fails on drives other than
the system drive.
Revert the changes introduced by commit 605972390.
This saves 192 bytes.
(GitHub issue #239)
Diffstat (limited to 'win32')
-rw-r--r-- | win32/mingw.c | 11 | ||||
-rw-r--r-- | win32/process.c | 4 |
2 files changed, 7 insertions, 8 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index d5d944a9d..606a48319 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -2142,13 +2142,12 @@ const char *need_system_drive(const char *path) | |||
2142 | return NULL; | 2142 | return NULL; |
2143 | } | 2143 | } |
2144 | 2144 | ||
2145 | /* Allocate a string long enough to allow a system drive prefix and | 2145 | /* Copy path to an allocated string long enough to allow a file extension |
2146 | * file extension to be added to path. Add the prefix if necessary. */ | 2146 | * to be added. */ |
2147 | char *alloc_system_drive(const char *path) | 2147 | char *alloc_ext_space(const char *path) |
2148 | { | 2148 | { |
2149 | const char *sd = need_system_drive(path); | 2149 | char *s = xmalloc(strlen(path) + 5); |
2150 | char *s = xmalloc(strlen(path) + 5 + (sd ? strlen(sd) : 0)); | 2150 | strcpy(s, path); |
2151 | strcpy(stpcpy(s, sd ?: ""), path); | ||
2152 | return s; | 2151 | return s; |
2153 | } | 2152 | } |
2154 | 2153 | ||
diff --git a/win32/process.c b/win32/process.c index 6ab0d8735..d78041251 100644 --- a/win32/process.c +++ b/win32/process.c | |||
@@ -328,7 +328,7 @@ mingw_spawn_interpreter(int mode, const char *prog, char *const *argv, | |||
328 | } | 328 | } |
329 | #endif | 329 | #endif |
330 | 330 | ||
331 | path = alloc_system_drive(interp.path); | 331 | path = alloc_ext_space(interp.path); |
332 | if ((add_win32_extension(path) || file_is_executable(path))) { | 332 | if ((add_win32_extension(path) || file_is_executable(path))) { |
333 | new_argv[0] = path; | 333 | new_argv[0] = path; |
334 | ret = mingw_spawn_interpreter(mode, path, new_argv, envp, level); | 334 | ret = mingw_spawn_interpreter(mode, path, new_argv, envp, level); |
@@ -363,7 +363,7 @@ mingw_spawnvp(int mode, const char *cmd, char *const *argv) | |||
363 | return mingw_spawn_applet(mode, argv, NULL); | 363 | return mingw_spawn_applet(mode, argv, NULL); |
364 | #endif | 364 | #endif |
365 | if (has_path(cmd)) { | 365 | if (has_path(cmd)) { |
366 | path = alloc_system_drive(cmd); | 366 | path = alloc_ext_space(cmd); |
367 | if (add_win32_extension(path) || file_is_executable(path)) { | 367 | if (add_win32_extension(path) || file_is_executable(path)) { |
368 | ret = mingw_spawn_interpreter(mode, path, argv, NULL, 0); | 368 | ret = mingw_spawn_interpreter(mode, path, argv, NULL, 0); |
369 | free(path); | 369 | free(path); |