aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-07-11 15:04:39 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-07-11 15:04:39 +0200
commit011a13463f7dbeafad0e168c365dcda291083cf4 (patch)
tree6931371acaac80726a3fcc8008a731c081ea782c
parente6dcea66ddd8e469a543145e9b449b990a450afb (diff)
downloadmblaze-011a13463f7dbeafad0e168c365dcda291083cf4.tar.gz
mlist: squeeze slashes from directory names
Closes #65.
-rw-r--r--mlist.c13
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;