From f72312908b11605f527d002b4e8ce729bbe237a5 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 4 Jan 2024 10:56:11 +0000 Subject: 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(). --- libbb/get_last_path_component.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'libbb/get_last_path_component.c') 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) */ char* FAST_FUNC bb_get_last_path_component_strip(char *path) { - char *slash = last_char_is(path, '/'); - #if ENABLE_PLATFORM_MINGW32 + char *slash = last_char_is_dir_sep(path); const char *start = has_dos_drive_prefix(path) ? path+2 : path; - if (!slash) - slash = last_char_is(path, '\\'); - if (slash) - while ((*slash == '/' || *slash == '\\') && slash != start) + while (is_dir_sep(*slash) && slash != start) *slash-- = '\0'; #else + char *slash = last_char_is(path, '/'); + if (slash) while (*slash == '/' && slash != path) *slash-- = '\0'; -- cgit v1.2.3-55-g6feb