summaryrefslogtreecommitdiff
path: root/usr.bin/mg
diff options
context:
space:
mode:
authorVincent Labrecque <vincent@cvs.openbsd.org>2003-08-15 23:09:58 +0000
committerVincent Labrecque <vincent@cvs.openbsd.org>2003-08-15 23:09:58 +0000
commit3a5ca0b5fae2904ddbce7f3f19d23a8eafbcfc25 (patch)
tree34123b72083d35f4703808694673037f2a18ea25 /usr.bin/mg
parenta532b274cecd7b60bcb65ab26e1b31bd3b0d1b04 (diff)
actually extract the filename off the ls line. makes dired *slightly*
more useful.
Diffstat (limited to 'usr.bin/mg')
-rw-r--r--usr.bin/mg/fileio.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/usr.bin/mg/fileio.c b/usr.bin/mg/fileio.c
index 0b903e412cd..478f5db1e19 100644
--- a/usr.bin/mg/fileio.c
+++ b/usr.bin/mg/fileio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fileio.c,v 1.36 2003/05/08 12:37:13 vincent Exp $ */
+/* $OpenBSD: fileio.c,v 1.37 2003/08/15 23:09:57 vincent Exp $ */
/*
* POSIX fileio.c
@@ -14,6 +14,7 @@ static FILE *ffp;
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
+#include <ctype.h>
/*
* Open a file for reading.
@@ -435,17 +436,20 @@ int
d_makename(LINE *lp, char *fn, int len)
{
int i;
- char *p, *np;
+ char *p, *ep;
strlcpy(fn, curbp->b_fname, len);
p = lp->l_text;
+ ep = lp->l_text + llength(lp);
for (i = 0; i < NAME_FIELD; i++) {
- np = strpbrk(p, "\t ");
- if (np == NULL)
- return ABORT;
- p = np + 1;
- while (*p != '\0' && strchr("\t ", *p))
+ while (p < ep && isspace(*p))
p++;
+ while (p < ep && !isspace(*p))
+ p++;
+ while (p < ep && isspace(*p))
+ p++;
+ if (p == ep)
+ return (ABORT);
}
strlcat(fn, p, len);
return lgetc(lp, 2) == 'd';