chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e3e2901
)
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
Sven Eden
<yamakuzure@gmx.net>
Wed, 30 May 2018 05:50:10 +0000
(07:50 +0200)
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 a044547263722d67d495e6e040e113a4d876f011..2be77126c126ca4a0d9df99ad62aeaea567a997b 100644
(file)
--- a/
src/basic/path-util.c
+++ b/
src/basic/path-util.c
@@
-85,7
+85,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);
}
#endif // 0