1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 17:51:22 +03:00

basic/path-util: line-break PATH_FOREACH_PREFIX macros

Now I can see what they do :]
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-12-07 16:16:39 +01:00
parent 296acffe45
commit f8703ed7e5

View File

@ -98,11 +98,23 @@ int mkfs_exists(const char *fstype);
* the tree, to root. Also returns "" (and not "/"!) for the root
* directory. Excludes the specified directory itself */
#define PATH_FOREACH_PREFIX(prefix, path) \
for (char *_slash = ({ path_simplify(strcpy(prefix, path), false); streq(prefix, "/") ? NULL : strrchr(prefix, '/'); }); _slash && ((*_slash = 0), true); _slash = strrchr((prefix), '/'))
for (char *_slash = ({ \
path_simplify(strcpy(prefix, path), false); \
streq(prefix, "/") ? NULL : strrchr(prefix, '/'); \
}); \
_slash && ((*_slash = 0), true); \
_slash = strrchr((prefix), '/'))
/* Same as PATH_FOREACH_PREFIX but also includes the specified path itself */
#define PATH_FOREACH_PREFIX_MORE(prefix, path) \
for (char *_slash = ({ path_simplify(strcpy(prefix, path), false); if (streq(prefix, "/")) prefix[0] = 0; strrchr(prefix, 0); }); _slash && ((*_slash = 0), true); _slash = strrchr((prefix), '/'))
for (char *_slash = ({ \
path_simplify(strcpy(prefix, path), false); \
if (streq(prefix, "/")) \
prefix[0] = 0; \
strrchr(prefix, 0); \
}); \
_slash && ((*_slash = 0), true); \
_slash = strrchr((prefix), '/'))
char *prefix_root(const char *root, const char *path);