summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-04-05 18:00:39 +0200
committerLennart Poettering <lennart@poettering.net>2018-04-12 11:02:47 +0200
commit8460289f3579e3f6ac691db78f7f33ffbcfe809d (patch)
tree95edf2a0b6267e6d4027b5468c5bffbead8f07c2 /src/basic
parent342f6f80f532a900667349e6c78c04ecd54ca6dc (diff)
downloadsystemd-8460289f3579e3f6ac691db78f7f33ffbcfe809d.tar.gz
path-util: document a few other special cases for last_path_component()
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/path-util.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/basic/path-util.c b/src/basic/path-util.c
index 4f89de0a72..5572c21952 100644
--- a/src/basic/path-util.c
+++ b/src/basic/path-util.c
@@ -715,16 +715,23 @@ char* dirname_malloc(const char *path) {
}
const char *last_path_component(const char *path) {
- /* Finds the last component of the path, preserving the
- * optional trailing slash that signifies a directory.
+
+ /* Finds the last component of the path, preserving the optional trailing slash that signifies a directory.
+ *
* a/b/c → c
* a/b/c/ → c/
+ * x → x
+ * x/ → x/
+ * /y → y
+ * /y/ → y/
* / → /
* // → /
* /foo/a → a
* /foo/a/ → a/
- * This is different than basename, which returns "" when
- * a trailing slash is present.
+ *
+ * Also, the empty string is mapped to itself.
+ *
+ * This is different than basename(), which returns "" when a trailing slash is present.
*/
unsigned l, k;