summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2007-10-05 19:28:24 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2007-10-05 19:28:24 +0000
commit91be8bab3c8cdead892a30c54b7f364fb936ae7c (patch)
tree2a6d009cb6176dd7fbe0e5d09e2047f70b0b9766 /usr.bin/cvs
parent16fbc333c2309760bf1d04d61e76b3e3d72cfba3 (diff)
strcspn() change
was okay'd by pyr@ and ok by millert@
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/edit.c7
-rw-r--r--usr.bin/cvs/entries.c11
-rw-r--r--usr.bin/cvs/file.c18
-rw-r--r--usr.bin/cvs/root.c9
-rw-r--r--usr.bin/cvs/util.c5
5 files changed, 16 insertions, 34 deletions
diff --git a/usr.bin/cvs/edit.c b/usr.bin/cvs/edit.c
index 59178612c6c..988d4a24ef0 100644
--- a/usr.bin/cvs/edit.c
+++ b/usr.bin/cvs/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.38 2007/09/24 22:06:28 joris Exp $ */
+/* $OpenBSD: edit.c,v 1.39 2007/10/05 19:28:23 gilles Exp $ */
/*
* Copyright (c) 2006, 2007 Xavier Santolaria <xsa@openbsd.org>
*
@@ -425,7 +425,6 @@ cvs_base_handle(struct cvs_file *cf, int flags)
{
FILE *fp, *tfp;
RCSNUM *ba_rev;
- size_t len;
int i;
char *dp, *sp;
char buf[MAXPATHLEN], *fields[2], rbuf[CVS_REV_BUFSZ];
@@ -449,9 +448,7 @@ cvs_base_handle(struct cvs_file *cf, int flags)
if (fp != NULL) {
while(fgets(buf, sizeof(buf), fp)) {
- len = strlen(buf);
- if (len > 0 && buf[len - 1] == '\n')
- buf[len - 1] = '\0';
+ buf[strcspn(buf, "\n")] = '\0';
if (buf[0] != 'B')
continue;
diff --git a/usr.bin/cvs/entries.c b/usr.bin/cvs/entries.c
index d1ac4eec8c3..a15f1908e37 100644
--- a/usr.bin/cvs/entries.c
+++ b/usr.bin/cvs/entries.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: entries.c,v 1.83 2007/09/25 11:10:28 chl Exp $ */
+/* $OpenBSD: entries.c,v 1.84 2007/10/05 19:28:23 gilles Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -32,7 +32,6 @@ CVSENTRIES *
cvs_ent_open(const char *dir)
{
FILE *fp;
- size_t len;
CVSENTRIES *ep;
char *p, buf[MAXPATHLEN];
struct cvs_ent *ent;
@@ -58,9 +57,7 @@ cvs_ent_open(const char *dir)
if ((fp = fopen(ep->cef_path, "r")) != NULL) {
while (fgets(buf, sizeof(buf), fp)) {
- len = strlen(buf);
- if (len > 0 && buf[len - 1] == '\n')
- buf[len - 1] = '\0';
+ buf[strcspn(buf, "\n")] = '\0';
if (buf[0] == 'D' && buf[1] == '\0')
break;
@@ -75,9 +72,7 @@ cvs_ent_open(const char *dir)
if ((fp = fopen(ep->cef_lpath, "r")) != NULL) {
while (fgets(buf, sizeof(buf), fp)) {
- len = strlen(buf);
- if (len > 0 && buf[len - 1] == '\n')
- buf[len - 1] = '\0';
+ buf[strcspn(buf, "\n")] = '\0';
p = &buf[1];
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c
index 1cb73459a82..8cf2ecd79fb 100644
--- a/usr.bin/cvs/file.c
+++ b/usr.bin/cvs/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.202 2007/09/24 13:44:20 joris Exp $ */
+/* $OpenBSD: file.c,v 1.203 2007/10/05 19:28:23 gilles Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -83,7 +83,6 @@ cvs_file_init(void)
{
int i;
FILE *ifp;
- size_t len;
char path[MAXPATHLEN], buf[MAXNAMLEN];
TAILQ_INIT(&cvs_ign_pats);
@@ -106,11 +105,9 @@ cvs_file_init(void)
"failed to open user's cvsignore file `%s'", path);
} else {
while (fgets(buf, MAXNAMLEN, ifp) != NULL) {
- len = strlen(buf);
- if (len == 0)
+ buf[strcspn(buf, "\n")] = '\0';
+ if (buf[0] == '\0')
continue;
- if (buf[len - 1] == '\n')
- buf[len - 1] = '\0';
cvs_file_ignore(buf, &cvs_ign_pats);
}
@@ -351,7 +348,6 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
int l, type;
FILE *fp;
int nbytes;
- size_t len;
long base;
size_t bufsize;
struct stat st;
@@ -396,11 +392,9 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
if ((fp = fopen(fpath, "r")) != NULL) {
while (fgets(fpath, MAXPATHLEN, fp) != NULL) {
- len = strlen(fpath);
- if (len == 0)
+ fpath[strcspn(fpath, "\n")] = '\0';
+ if (fpath[0] == '\0')
continue;
- if (fpath[len - 1] == '\n')
- fpath[len - 1] = '\0';
cvs_file_ignore(fpath, &dir_ign_pats);
}
@@ -439,7 +433,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
continue;
}
- len = xsnprintf(fpath, MAXPATHLEN, "%s/%s",
+ (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s",
cf->file_path, dp->d_name);
/*
diff --git a/usr.bin/cvs/root.c b/usr.bin/cvs/root.c
index 99258fbc87f..6c45f25a903 100644
--- a/usr.bin/cvs/root.c
+++ b/usr.bin/cvs/root.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: root.c,v 1.43 2007/09/10 19:11:08 joris Exp $ */
+/* $OpenBSD: root.c,v 1.44 2007/10/05 19:28:23 gilles Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -165,7 +165,6 @@ cvsroot_parse(const char *str)
struct cvsroot *
cvsroot_get(const char *dir)
{
- size_t len;
char rootpath[MAXPATHLEN], *rootstr, line[128];
FILE *fp;
@@ -195,11 +194,9 @@ cvsroot_get(const char *dir)
(void)fclose(fp);
- len = strlen(line);
- if (len == 0)
+ line[strcspn(line, "\n")] = '\0';
+ if (line[0] == '\0')
cvs_log(LP_ERR, "empty %s file", CVS_PATH_ROOTSPEC);
- else if (line[len - 1] == '\n')
- line[--len] = '\0';
return cvsroot_parse(line);
}
diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c
index 316263e8957..b11452c8020 100644
--- a/usr.bin/cvs/util.c
+++ b/usr.bin/cvs/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.119 2007/09/22 16:01:22 joris Exp $ */
+/* $OpenBSD: util.c,v 1.120 2007/10/05 19:28:23 gilles Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
@@ -585,8 +585,7 @@ cvs_mkpath(const char *path, char *tag)
if ((fp = fopen(CVS_PATH_REPOSITORY, "r")) != NULL) {
if ((fgets(repo, sizeof(repo), fp)) == NULL)
fatal("cvs_mkpath: bad repository file");
- if ((len = strlen(repo)) && repo[len - 1] == '\n')
- repo[len - 1] = '\0';
+ repo[strcspn(repo, "\n")] = '\0';
(void)fclose(fp);
}
}