diff options
author | 2003-08-15 23:09:57 +0000 | |
---|---|---|
committer | 2003-08-15 23:09:57 +0000 | |
commit | 6f43aaee4091b835964ee68eae4bc73805b7512e (patch) | |
tree | ab7c89572a1c4926c994dbecb04c437e45d24b8a | |
parent | - remove ahc dependency, convert smc93cx6 into an attribute. (diff) | |
download | wireguard-openbsd-6f43aaee4091b835964ee68eae4bc73805b7512e.tar.xz wireguard-openbsd-6f43aaee4091b835964ee68eae4bc73805b7512e.zip |
actually extract the filename off the ls line. makes dired *slightly*
more useful.
-rw-r--r-- | usr.bin/mg/fileio.c | 18 |
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'; |