diff options
author | Ron Yorston <rmy@pobox.com> | 2020-08-23 10:16:12 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2020-08-23 10:16:12 +0100 |
commit | 64ecd10486934c12336dac84c67a1939dce0e096 (patch) | |
tree | 73e8bc6b07176b84295fd07f19828292a240f693 /debianutils | |
parent | d6b557547551dd80a389f361a995a97ef5930a63 (diff) | |
download | busybox-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 'debianutils')
-rw-r--r-- | debianutils/which.c | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/debianutils/which.c b/debianutils/which.c index 384e2cfec..1d23786b8 100644 --- a/debianutils/which.c +++ b/debianutils/which.c | |||
@@ -45,10 +45,8 @@ int which_main(int argc UNUSED_PARAM, char **argv) | |||
45 | 45 | ||
46 | do { | 46 | do { |
47 | int missing = 1; | 47 | int missing = 1; |
48 | #if ENABLE_PLATFORM_MINGW32 | ||
49 | char *p; | ||
50 | 48 | ||
51 | # if ENABLE_FEATURE_SH_STANDALONE | 49 | #if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE |
52 | if (strcmp(*argv, "busybox") == 0 && | 50 | if (strcmp(*argv, "busybox") == 0 && |
53 | is_suffixed_with(bb_busybox_exec_path, "busybox.exe")) { | 51 | is_suffixed_with(bb_busybox_exec_path, "busybox.exe")) { |
54 | missing = 0; | 52 | missing = 0; |
@@ -63,44 +61,36 @@ int which_main(int argc UNUSED_PARAM, char **argv) | |||
63 | if (!option_mask32) /* -a not set */ | 61 | if (!option_mask32) /* -a not set */ |
64 | break; | 62 | break; |
65 | } | 63 | } |
66 | # endif | ||
67 | #endif | 64 | #endif |
68 | 65 | ||
69 | /* If file contains a slash don't use PATH */ | ||
70 | #if !ENABLE_PLATFORM_MINGW32 | 66 | #if !ENABLE_PLATFORM_MINGW32 |
67 | /* If file contains a slash don't use PATH */ | ||
71 | if (strchr(*argv, '/')) { | 68 | if (strchr(*argv, '/')) { |
69 | if (file_is_executable(*argv)) { | ||
70 | missing = 0; | ||
71 | puts(*argv); | ||
72 | } | ||
72 | #else | 73 | #else |
73 | if (has_path(*argv)) { | 74 | if (has_path(*argv)) { |
74 | # if ENABLE_FEATURE_SH_STANDALONE | 75 | # if ENABLE_FEATURE_SH_STANDALONE |
75 | const char *name = bb_basename(*argv); | 76 | const char *name = bb_basename(*argv); |
76 | int is_unix_path = unix_path(*argv); | ||
77 | # endif | 77 | # endif |
78 | *argv = auto_add_system_drive(*argv); | 78 | char *path = alloc_system_drive(*argv); |
79 | if ((p=auto_win32_extension(*argv)) != NULL) { | 79 | |
80 | missing = 0; | 80 | if (add_win32_extension(path) || file_is_executable(path)) { |
81 | puts(bs_to_slash(p)); | ||
82 | } | ||
83 | else | ||
84 | #endif | ||
85 | if (file_is_executable(*argv)) { | ||
86 | missing = 0; | 81 | missing = 0; |
87 | #if ENABLE_PLATFORM_MINGW32 | 82 | puts(bs_to_slash(path)); |
88 | puts(bs_to_slash(auto_string(xstrdup(*argv)))); | ||
89 | #else | ||
90 | puts(*argv); | ||
91 | #endif | ||
92 | } | 83 | } |
93 | #if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_STANDALONE | 84 | # if ENABLE_FEATURE_SH_STANDALONE |
94 | else if (is_unix_path && find_applet_by_name(name) >= 0) { | 85 | else if (unix_path(*argv) && find_applet_by_name(name) >= 0) { |
95 | missing = 0; | 86 | missing = 0; |
96 | puts(name); | 87 | puts(name); |
97 | } | 88 | } |
89 | # endif | ||
98 | #endif | 90 | #endif |
99 | } else { | 91 | } else { |
100 | char *path; | 92 | char *path; |
101 | #if !ENABLE_PLATFORM_MINGW32 | ||
102 | char *p; | 93 | char *p; |
103 | #endif | ||
104 | 94 | ||
105 | path = env_path; | 95 | path = env_path; |
106 | /* NOFORK NB: xmalloc inside find_executable(), must have no allocs above! */ | 96 | /* NOFORK NB: xmalloc inside find_executable(), must have no allocs above! */ |