diff options
author | Ron Yorston <rmy@pobox.com> | 2024-01-04 10:56:11 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-01-04 10:56:11 +0000 |
commit | f72312908b11605f527d002b4e8ce729bbe237a5 (patch) | |
tree | c7bec503c0c74ab6ee41c6c8001ab45e62ea1c8a /libbb/get_last_path_component.c | |
parent | 0bbb4f442b862190fbddc4603f786787ba5a09f0 (diff) | |
download | busybox-w32-f72312908b11605f527d002b4e8ce729bbe237a5.tar.gz busybox-w32-f72312908b11605f527d002b4e8ce729bbe237a5.tar.bz2 busybox-w32-f72312908b11605f527d002b4e8ce729bbe237a5.zip |
libbb: code shrink bb_get_last_path_component_strip()
Use the new function last_char_is_dir_sep() to save 16 bytes in
bb_get_last_path_component_strip().
Diffstat (limited to 'libbb/get_last_path_component.c')
-rw-r--r-- | libbb/get_last_path_component.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/libbb/get_last_path_component.c b/libbb/get_last_path_component.c index 254aabafd..9d017ab7f 100644 --- a/libbb/get_last_path_component.c +++ b/libbb/get_last_path_component.c | |||
@@ -72,18 +72,16 @@ char* FAST_FUNC bb_get_last_path_component_nostrip(const char *path) | |||
72 | */ | 72 | */ |
73 | char* FAST_FUNC bb_get_last_path_component_strip(char *path) | 73 | char* FAST_FUNC bb_get_last_path_component_strip(char *path) |
74 | { | 74 | { |
75 | char *slash = last_char_is(path, '/'); | ||
76 | |||
77 | #if ENABLE_PLATFORM_MINGW32 | 75 | #if ENABLE_PLATFORM_MINGW32 |
76 | char *slash = last_char_is_dir_sep(path); | ||
78 | const char *start = has_dos_drive_prefix(path) ? path+2 : path; | 77 | const char *start = has_dos_drive_prefix(path) ? path+2 : path; |
79 | 78 | ||
80 | if (!slash) | ||
81 | slash = last_char_is(path, '\\'); | ||
82 | |||
83 | if (slash) | 79 | if (slash) |
84 | while ((*slash == '/' || *slash == '\\') && slash != start) | 80 | while (is_dir_sep(*slash) && slash != start) |
85 | *slash-- = '\0'; | 81 | *slash-- = '\0'; |
86 | #else | 82 | #else |
83 | char *slash = last_char_is(path, '/'); | ||
84 | |||
87 | if (slash) | 85 | if (slash) |
88 | while (*slash == '/' && slash != path) | 86 | while (*slash == '/' && slash != path) |
89 | *slash-- = '\0'; | 87 | *slash-- = '\0'; |