projects
/
platform
/
upstream
/
systemd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
81cce8d
)
path-util: don't add extra "/" when prefix already is suffixed by slash
author
Lennart Poettering
<lennart@poettering.net>
Wed, 17 Jan 2018 10:15:00 +0000
(11:15 +0100)
committer
Lennart Poettering
<lennart@poettering.net>
Wed, 17 Jan 2018 10:15:00 +0000
(11:15 +0100)
No need to insert duplicate "/" if we can avoid it. This is particularly
relevant if the prefix passed in is the root directory.
src/basic/path-util.c
patch
|
blob
|
history
diff --git
a/src/basic/path-util.c
b/src/basic/path-util.c
index
b877bdc
..
f5f506c
100644
(file)
--- a/
src/basic/path-util.c
+++ b/
src/basic/path-util.c
@@
-84,7
+84,10
@@
char *path_make_absolute(const char *p, const char *prefix) {
if (path_is_absolute(p) || isempty(prefix))
return strdup(p);
- return strjoin(prefix, "/", p);
+ if (endswith(prefix, "/"))
+ return strjoin(prefix, p);
+ else
+ return strjoin(prefix, "/", p);
}
int path_make_absolute_cwd(const char *p, char **ret) {