diff options
author | William Wilgus <wilgus.william@gmail.com> | 2024-06-16 12:33:16 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2024-06-16 12:33:16 -0400 |
commit | 7b12cc39270c41459ffe98659d9899d02d8bf56b (patch) | |
tree | 731ec7633e27becc0dffbfe365d960eee7614e21 | |
parent | ae25a425b6dc1689f35afd77e8064912e4b30a60 (diff) | |
download | rockbox-7b12cc3927.tar.gz rockbox-7b12cc3927.zip |
pathfuncs.c remove strip_leading_separators()
This should actually be strip_extra_leading_separators() but
its not used anywhere else yet and I don't see enough callers
in core to make it worth the extra overhead
Change-Id: Icdd292869b4198bed7725c51820f6b2111ad739d
-rw-r--r-- | firmware/common/pathfuncs.c | 23 | ||||
-rw-r--r-- | firmware/export/pathfuncs.h | 1 |
2 files changed, 4 insertions, 20 deletions
diff --git a/firmware/common/pathfuncs.c b/firmware/common/pathfuncs.c index e9218ea2c7..db3abe6940 100644 --- a/firmware/common/pathfuncs.c +++ b/firmware/common/pathfuncs.c @@ -339,23 +339,6 @@ size_t path_dirname(const char *name, const char **nameptr) return q - name; } -/* Removes leading separators from a path - * "" *nameptr->NUL, count=0: "" - * "/" *nameptr->/, count=1: "/" - * "//" *nameptr->2nd /, count=2: "/" - * "a/" *nameptr->a/, count=0: "a/" - * "//b//" *nameptr->2nd /, count=2: "/b//" - * "/c/" *nameptr->/, count=1: "/c/" - */ -size_t path_strip_leading_separators(const char *name, const char **nameptr) -{ - const char *p = name; - *nameptr = p; - while (*(p) == PATH_SEPCH && *(++p) == PATH_SEPCH) - *nameptr = p; - return p - name; -} - /* Removes trailing separators from a path * "" *nameptr->NUL, len=0: "" * "/" *nameptr->/, len=1: "/" @@ -503,9 +486,11 @@ size_t path_append_ex(char *buf, const char *basepath, size_t basepath_max, len = strlen(buf); else if (basepath) { - path_strip_leading_separators(basepath, &basepath); + /* strip extra leading separators */ + while (*basepath == PATH_SEPCH && *(basepath + 1) == PATH_SEPCH) + basepath++; len = strlcpy(buf, basepath, bufsize); - if (basepath_max < len) + if (basepath_max < len) /*if needed truncate basepath to basepath_max */ { len = basepath_max; buf[basepath_max] = '\0'; diff --git a/firmware/export/pathfuncs.h b/firmware/export/pathfuncs.h index 03495e5ab2..1b18f22d06 100644 --- a/firmware/export/pathfuncs.h +++ b/firmware/export/pathfuncs.h @@ -87,7 +87,6 @@ int make_volume_root(int volume, char *dst); int path_strip_drive(const char *name, const char **nameptr, bool greedy); size_t path_basename(const char *name, const char **nameptr); size_t path_dirname(const char *name, const char **nameptr); -size_t path_strip_leading_separators(const char *name, const char **nameptr); size_t path_strip_trailing_separators(const char *name, const char **nameptr); void path_correct_separators(char *dstpath, const char *path); void path_remove_dot_segments(char *dstpath, const char *path); |