mblaze

Unix utilities to deal with Maildir - my mirror
git clone https://pi.duncano.de/git/mblaze.git
Log | Files | Refs | README | COPYING

commit 157542c3e7dd3eb89401bd3a8397693d4818efd8
parent 73d80d80f98436aff9b3ce8b99089d5f909e7c63
Author: Leah Neukirchen <leah@vuxu.org>
Date:   Wed, 12 Jul 2017 22:31:01 +0200

mlist: extract squeeze_slash

Diffstat:
GNUmakefile | 1+
blaze822.h | 3+++
mlist.c | 12+-----------
squeeze_slash.c | 15+++++++++++++++
4 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/GNUmakefile b/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' \ diff --git a/blaze822.h b/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 *); diff --git a/mlist.c b/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) diff --git a/squeeze_slash.c b/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; +}