diff options
author | Stef Walter <stef@thewalter.net> | 2013-07-17 15:53:33 +0200 |
---|---|---|
committer | Stef Walter <stef@thewalter.net> | 2013-07-18 06:53:11 +0200 |
commit | 3f9da410144fd45ee6250dda28cae49300077e29 (patch) | |
tree | c5ea2e0713907958ef1498e93f6547855ff11210 /common | |
parent | 82738fe7d6143cb25fc1cb201a75b8a071043be8 (diff) |
Fixes for some recent win32 regressions
Diffstat (limited to 'common')
-rw-r--r-- | common/path.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/common/path.c b/common/path.c index 89d9a67..818befc 100644 --- a/common/path.c +++ b/common/path.c @@ -228,6 +228,7 @@ p11_path_build (const char *path, size_t len; size_t at; size_t num; + size_t until; va_list va; return_val_if_fail (path != NULL, NULL); @@ -247,14 +248,28 @@ p11_path_build (const char *path, path = first; va_start (va, path); while (path != NULL) { - if (at != 0 && built[at - 1] != delim && path[0] != delim) - built[at++] = delim; num = strlen (path); + + /* Trim end of the path */ + until = (at > 0) ? 0 : 1; + while (num > until && is_path_component_or_null (path[num - 1])) + num--; + + if (at != 0) { + if (num == 0) + continue; + built[at++] = delim; + } + assert (at + num < len); memcpy (built + at, path, num); - at += num; + path = va_arg (va, const char *); + + /* Trim beginning of path */ + while (path && path[0] && is_path_component_or_null (path[0])) + path++; } va_end (va); |