about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--GNUmakefile1
-rw-r--r--blaze822.h3
-rw-r--r--mlist.c12
-rw-r--r--squeeze_slash.c15
4 files changed, 20 insertions, 11 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 0058e81..a6062ee 100644
--- 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
index a5cb008..45ee66a 100644
--- 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
index 8ad53f9..d796fc7 100644
--- 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
new file mode 100644
index 0000000..b493cd1
--- /dev/null
+++ 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;
+}