From 799264dcf2ced28bb8d2bdb25dcc084887a6c9da Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 28 Mar 2011 03:39:39 +0000 Subject: Fix LV2_PATH parsing. git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@3131 a436a847-0d15-0410-975c-d299462d15a1 --- src/world.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/world.c b/src/world.c index ea2e20c..39262e6 100644 --- a/src/world.c +++ b/src/world.c @@ -26,6 +26,7 @@ #define _XOPEN_SOURCE 500 #include +#include #include #include @@ -577,17 +578,15 @@ is_path_sep(char c) return c == SLV2_PATH_SEP[0]; } -const char* -last_path_sep(const char* path) +static const char* +first_path_sep(const char* path) { - const size_t len = strlen(path); - const char* last_sep = path + len; - for (; last_sep > path; --last_sep) { - if (is_path_sep(*last_sep)) { - break; + for (const char* p = path; *p != '\0'; ++p) { + if (is_path_sep(*p)) { + return p; } } - return is_path_sep(*last_sep) ? last_sep : NULL; + return NULL; } /** Load all bundles found in @a lv2_path. @@ -600,7 +599,7 @@ slv2_world_load_path(SLV2World world, const char* lv2_path) { while (lv2_path[0] != '\0') { - const char* const sep = last_path_sep(lv2_path); + const char* const sep = first_path_sep(lv2_path); if (sep) { const size_t dir_len = sep - lv2_path; char* const dir = malloc(dir_len + 1); -- cgit v1.2.1