From 1e2c11636861da69c5637e59afe207a11dd4f386 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 30 Oct 2016 10:21:29 -0400 Subject: [PATCH] tests: clarify test_path_startswith return value (#4508) A pendant for #4481. --- src/basic/path-util.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/basic/path-util.c b/src/basic/path-util.c index cdbb2d398..3af95bf24 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -356,6 +356,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; -- 2.30.2