diff options
author | Ron Yorston <rmy@pobox.com> | 2018-12-06 15:16:49 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-12-06 15:16:49 +0000 |
commit | 9906faf2dff6fd9033cb711619528501cae11721 (patch) | |
tree | a85bb3ee78f5d58378f23842e0e762e879db23bc /include/mingw.h | |
parent | d257c7f2b6c44662c793d00d0b9286d6246b84a3 (diff) | |
download | busybox-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 'include/mingw.h')
-rw-r--r-- | include/mingw.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/include/mingw.h b/include/mingw.h index 025c4e22b..543172075 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -457,7 +457,16 @@ void init_winsock(void); | |||
457 | int has_bat_suffix(const char *p); | 457 | int has_bat_suffix(const char *p); |
458 | int has_exe_suffix(const char *p); | 458 | int has_exe_suffix(const char *p); |
459 | int has_exe_suffix_or_dot(const char *name); | 459 | int has_exe_suffix_or_dot(const char *name); |
460 | char *add_win32_extension(const char *p); | 460 | char *alloc_win32_extension(const char *p); |
461 | int add_win32_extension(char *p); | ||
462 | |||
463 | static inline char *auto_win32_extension(const char *p) | ||
464 | { | ||
465 | extern char *auto_string(char *str) FAST_FUNC; | ||
466 | char *s = alloc_win32_extension(p); | ||
467 | return s ? auto_string(s) : NULL; | ||
468 | } | ||
469 | |||
461 | void FAST_FUNC convert_slashes(char *p); | 470 | void FAST_FUNC convert_slashes(char *p); |
462 | 471 | ||
463 | int err_win_to_posix(DWORD winerr); | 472 | int err_win_to_posix(DWORD winerr); |