diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-10-30 10:21:29 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-30 10:21:29 -0400 |
commit | 0470289b6e93be7a65b1b3b2a2cc829bd20e08c8 (patch) | |
tree | 8b4a8e3daa5f1305d9d97c3a94eb9547de50458f /src/basic | |
parent | 87b6ba21b5ca4aa9764f7e5a9495441348be0209 (diff) |
tests: clarify test_path_startswith return value (#4508)
A pendant for #4481.
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/path-util.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 0f5b20cf05..fd38f51c4c 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -354,6 +354,16 @@ char* path_startswith(const char *path, const char *prefix) { assert(path); assert(prefix); + /* Returns a pointer to the start of the first component after the parts matched by + * the prefix, iff + * - both paths are absolute or both paths are relative, + * and + * - each component in prefix in turn matches a component in path at the same position. + * An empty string will be returned when the prefix and path are equivalent. + * + * Returns NULL otherwise. + */ + if ((path[0] == '/') != (prefix[0] == '/')) return NULL; |