diff options
author | 2005-01-12 20:10:09 +0000 | |
---|---|---|
committer | 2005-01-12 20:10:09 +0000 | |
commit | aedac619a799f2c6986cef56902bc24b5bb09503 (patch) | |
tree | 0b589d8960f034f8c4c353796a40f86ff725f8e1 | |
parent | add rcs_kflag_get() to validate kflags (diff) | |
download | wireguard-openbsd-aedac619a799f2c6986cef56902bc24b5bb09503.tar.xz wireguard-openbsd-aedac619a799f2c6986cef56902bc24b5bb09503.zip |
use basename(3) instead of mangling the path to figure out the
filename ourselves. Removes a bunch of now useless code.
spotted by Joris Vink, diff by me
-rw-r--r-- | usr.bin/cvs/file.c | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c index 788ede4afe9..bd45a0aff75 100644 --- a/usr.bin/cvs/file.c +++ b/usr.bin/cvs/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.50 2005/01/11 00:01:14 jfb Exp $ */ +/* $OpenBSD: file.c,v 1.51 2005/01/12 20:10:09 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -32,6 +32,7 @@ #include <errno.h> #include <stdio.h> #include <fcntl.h> +#include <libgen.h> #include <dirent.h> #include <stdlib.h> #include <unistd.h> @@ -826,9 +827,6 @@ cvs_file_cmp(const void *f1, const void *f2) CVSFILE* cvs_file_alloc(const char *path, u_int type) { - size_t len; - char pbuf[MAXPATHLEN]; - const char *fnp; CVSFILE *cfp; struct cvs_dir *ddat; @@ -839,19 +837,7 @@ cvs_file_alloc(const char *path, u_int type) } memset(cfp, 0, sizeof(*cfp)); - /* ditch trailing slashes */ - strlcpy(pbuf, path, sizeof(pbuf)); - len = strlen(pbuf); - while (pbuf[len - 1] == '/') - pbuf[--len] = '\0'; - - fnp = strrchr(path, '/'); - if (fnp == NULL) - fnp = path; - else - fnp++; - - cfp->cf_name = cvs_file_getname(fnp); + cfp->cf_name = cvs_file_getname(basename(path)); if (cfp->cf_name == NULL) { cvs_log(LP_ERR, "failed to get file name from table"); return (NULL); |