1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-07 09:56:51 +03:00

path-util: don't add extra "/" when prefix already is suffixed by slash

No need to insert duplicate "/" if we can avoid it. This is particularly
relevant if the prefix passed in is the root directory.
This commit is contained in:
Lennart Poettering 2018-01-17 11:15:00 +01:00
parent 81cce8ded5
commit cddd2ce106

View File

@ -84,6 +84,9 @@ char *path_make_absolute(const char *p, const char *prefix) {
if (path_is_absolute(p) || isempty(prefix)) if (path_is_absolute(p) || isempty(prefix))
return strdup(p); return strdup(p);
if (endswith(prefix, "/"))
return strjoin(prefix, p);
else
return strjoin(prefix, "/", p); return strjoin(prefix, "/", p);
} }