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 /firmware/common/pathfuncs.c | |
parent | ae25a425b6dc1689f35afd77e8064912e4b30a60 (diff) | |
download | rockbox-7b12cc39270c41459ffe98659d9899d02d8bf56b.tar.gz rockbox-7b12cc39270c41459ffe98659d9899d02d8bf56b.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
Diffstat (limited to 'firmware/common/pathfuncs.c')
-rw-r--r-- | firmware/common/pathfuncs.c | 23 |
1 files changed, 4 insertions, 19 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) | |||
339 | return q - name; | 339 | return q - name; |
340 | } | 340 | } |
341 | 341 | ||
342 | /* Removes leading separators from a path | ||
343 | * "" *nameptr->NUL, count=0: "" | ||
344 | * "/" *nameptr->/, count=1: "/" | ||
345 | * "//" *nameptr->2nd /, count=2: "/" | ||
346 | * "a/" *nameptr->a/, count=0: "a/" | ||
347 | * "//b//" *nameptr->2nd /, count=2: "/b//" | ||
348 | * "/c/" *nameptr->/, count=1: "/c/" | ||
349 | */ | ||
350 | size_t path_strip_leading_separators(const char *name, const char **nameptr) | ||
351 | { | ||
352 | const char *p = name; | ||
353 | *nameptr = p; | ||
354 | while (*(p) == PATH_SEPCH && *(++p) == PATH_SEPCH) | ||
355 | *nameptr = p; | ||
356 | return p - name; | ||
357 | } | ||
358 | |||
359 | /* Removes trailing separators from a path | 342 | /* Removes trailing separators from a path |
360 | * "" *nameptr->NUL, len=0: "" | 343 | * "" *nameptr->NUL, len=0: "" |
361 | * "/" *nameptr->/, len=1: "/" | 344 | * "/" *nameptr->/, len=1: "/" |
@@ -503,9 +486,11 @@ size_t path_append_ex(char *buf, const char *basepath, size_t basepath_max, | |||
503 | len = strlen(buf); | 486 | len = strlen(buf); |
504 | else if (basepath) | 487 | else if (basepath) |
505 | { | 488 | { |
506 | path_strip_leading_separators(basepath, &basepath); | 489 | /* strip extra leading separators */ |
490 | while (*basepath == PATH_SEPCH && *(basepath + 1) == PATH_SEPCH) | ||
491 | basepath++; | ||
507 | len = strlcpy(buf, basepath, bufsize); | 492 | len = strlcpy(buf, basepath, bufsize); |
508 | if (basepath_max < len) | 493 | if (basepath_max < len) /*if needed truncate basepath to basepath_max */ |
509 | { | 494 | { |
510 | len = basepath_max; | 495 | len = basepath_max; |
511 | buf[basepath_max] = '\0'; | 496 | buf[basepath_max] = '\0'; |