diff options
author | Leah Neukirchen <leah@vuxu.org> | 2017-07-11 15:04:39 +0200 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2017-07-11 15:04:39 +0200 |
commit | 011a13463f7dbeafad0e168c365dcda291083cf4 (patch) | |
tree | 6931371acaac80726a3fcc8008a731c081ea782c | |
parent | e6dcea66ddd8e469a543145e9b449b990a450afb (diff) | |
download | mblaze-011a13463f7dbeafad0e168c365dcda291083cf4.tar.gz mblaze-011a13463f7dbeafad0e168c365dcda291083cf4.tar.xz mblaze-011a13463f7dbeafad0e168c365dcda291083cf4.zip |
mlist: squeeze slashes from directory names
Closes #65.
-rw-r--r-- | mlist.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/mlist.c b/mlist.c index 79bf286..725a76d 100644 --- a/mlist.c +++ b/mlist.c @@ -168,6 +168,19 @@ listdir(char *dir) void listarg(char *arg) { + char *s, *t; + + // squeeze slashes + s = t = arg; + while ((*s++ = *t)) + if (*t++ == '/') + while (*t == '/') + t++; + // remove trailing slashes + s--; + while (*--s == '/') + *s = 0; + struct stat st; if (stat(arg, &st) < 0) return; |