mlist: squeeze slashes from directory names

Closes #65.
This commit is contained in:
Leah Neukirchen 2017-07-11 15:04:39 +02:00
parent e6dcea66dd
commit 011a13463f

13
mlist.c
View File

@ -168,6 +168,19 @@ listdir(char *dir)
void void
listarg(char *arg) 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; struct stat st;
if (stat(arg, &st) < 0) if (stat(arg, &st) < 0)
return; return;