summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/misc.c b/misc.c
index 12fdd2a..4a5f6be 100644
--- a/misc.c
+++ b/misc.c
@@ -251,7 +251,8 @@ int is_dir(const char *path) {
void mkdirp(const char *path, int mode) {
char *str = make_str(path);
- for (char *p = find_delm(str, "/", *str == '/'); !is_empty(p); p = find_delm(p, "/", 1)) {
+ for (char *p = find_delm(str, "/", *str == '/'); !is_empty(p); p = find_delm(p, "/", *p == '/')) {
+ const size_t span = strspn(p, "/");
if (*p == '/') {
*p = '\0';
}
@@ -260,6 +261,9 @@ void mkdirp(const char *path, int mode) {
}
if (*p == '\0') {
*p = '/';
+ if (*find_delm(&p[span], "/", 0) != '\0') {
+ p += span;
+ }
}
}