ソースを参照

mlist: extract squeeze_slash

pull/69/head
Leah Neukirchen 5年前
コミット
157542c3e7
  1. 1
      GNUmakefile
  2. 3
      blaze822.h
  3. 12
      mlist.c
  4. 15
      squeeze_slash.c

1
GNUmakefile

@ -33,6 +33,7 @@ mshow : filter.o safe_u8putstr.o rfc2231.o pipeto.o
mscan : pipeto.o
msort : mystrverscmp.o
mmime : slurp.o
mlist : squeeze_slash.o
museragent: FRC
@printf '#!/bin/sh\nprintf "User-Agent: mblaze/%s (%s)\\n"\n' \

3
blaze822.h

@ -97,3 +97,6 @@ void safe_u8putstr(char *s0, size_t l, FILE *stream);
pid_t pipeto(const char *cmdline);
int pipeclose(pid_t pid);
// squeeze_slash.c
void squeeze_slash(char *);

12
mlist.c

@ -168,17 +168,7 @@ listdir(char *dir)
void
listarg(char *arg)
{
char *s, *t;
// squeeze slashes
s = t = arg;
while ((*s++ = *t))
while (*t++ == '/' && *t == '/')
;
// remove trailing slashes
s--;
while (*--s == '/')
*s = 0;
squeeze_slash(arg);
struct stat st;
if (stat(arg, &st) < 0)

15
squeeze_slash.c

@ -0,0 +1,15 @@
void
squeeze_slash(char *arg) {
char *s, *t;
// squeeze slashes
s = t = arg;
while ((*s++ = *t))
while (*t++ == '/' && *t == '/')
;
// remove trailing slashes
s--;
while (*--s == '/')
*s = 0;
}
読み込み中…
キャンセル
保存