summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-12-07 16:16:39 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-12-10 11:57:26 +0100
commitf8703ed7e51121cd42bfb05fe9fe2a626118b07b (patch)
treebf72cd8b6a54f65739bc904fea239f3a2fe45d4a /src
parent296acffe45a74a8c9cca393494760169b5a4afd3 (diff)
downloadsystemd-f8703ed7e51121cd42bfb05fe9fe2a626118b07b.tar.gz
basic/path-util: line-break PATH_FOREACH_PREFIX macros
Now I can see what they do :]
Diffstat (limited to 'src')
-rw-r--r--src/basic/path-util.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/basic/path-util.h b/src/basic/path-util.h
index 78db41b855..094aa47c01 100644
--- a/src/basic/path-util.h
+++ b/src/basic/path-util.h
@@ -97,12 +97,24 @@ int mkfs_exists(const char *fstype);
/* Iterates through the path prefixes of the specified path, going up
* 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), '/'))
+#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), '/'))
/* 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), '/'))
+#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), '/'))
char *prefix_root(const char *root, const char *path);