diff options
author | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2008-01-10 10:08:23 +0000 |
---|---|---|
committer | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2008-01-10 10:08:23 +0000 |
commit | 0f5cebe91fb780a119496047300ea893bae226c3 (patch) | |
tree | d411a6955ad123193ade15923e0ff9bd79a352a0 /usr.bin | |
parent | 1791d0588fc7a52ac71ad3cdd7bb28ddb8e53bdb (diff) |
another strcspn() round
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/cvs/add.c | 5 | ||||
-rw-r--r-- | usr.bin/cvs/checkout.c | 5 | ||||
-rw-r--r-- | usr.bin/cvs/client.c | 11 | ||||
-rw-r--r-- | usr.bin/cvs/edit.c | 11 | ||||
-rw-r--r-- | usr.bin/cvs/remove.c | 5 | ||||
-rw-r--r-- | usr.bin/cvs/update.c | 5 | ||||
-rw-r--r-- | usr.bin/cvs/util.c | 9 |
7 files changed, 19 insertions, 32 deletions
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c index 06d322d3b1f..37292753612 100644 --- a/usr.bin/cvs/add.c +++ b/usr.bin/cvs/add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: add.c,v 1.85 2008/01/10 09:44:32 tobias Exp $ */ +/* $OpenBSD: add.c,v 1.86 2008/01/10 10:08:22 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> @@ -381,8 +381,7 @@ add_entry(struct cvs_file *cf) rcsnum_tostr(cf->file_ent->ce_rev, revbuf, sizeof(revbuf)); ctime_r(&cf->file_ent->ce_mtime, tbuf); - if (tbuf[strlen(tbuf) - 1] == '\n') - tbuf[strlen(tbuf) - 1] = '\0'; + tbuf[strcspn(tbuf, "\n")] = '\0'; /* Remove the '-' prefixing the version number. */ (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c index 6fbd875f0a4..c2e892680f5 100644 --- a/usr.bin/cvs/checkout.c +++ b/usr.bin/cvs/checkout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: checkout.c,v 1.106 2008/01/10 09:54:04 tobias Exp $ */ +/* $OpenBSD: checkout.c,v 1.107 2008/01/10 10:08:22 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -315,8 +315,7 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags) } asctime_r(gmtime(&rcstime), tbuf); - if (tbuf[strlen(tbuf) - 1] == '\n') - tbuf[strlen(tbuf) - 1] = '\0'; + tbuf[strcspn(tbuf, "\n")] = '\0'; if (co_flags & CO_MERGE) { (void)xsnprintf(timebuf, sizeof(timebuf), "Result of merge+%s", diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c index 74a6a77f39b..53b41fbe35f 100644 --- a/usr.bin/cvs/client.c +++ b/usr.bin/cvs/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.87 2008/01/10 10:05:40 tobias Exp $ */ +/* $OpenBSD: client.c,v 1.88 2008/01/10 10:08:22 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -476,8 +476,7 @@ cvs_client_sendfile(struct cvs_file *cf) } if (cf->file_ent->ce_conflict == NULL) { - if (timebuf[strlen(timebuf) - 1] == '\n') - timebuf[strlen(timebuf) - 1] = '\0'; + timebuf[strcspn(timebuf, "\n")] = '\0'; } else { len = strlcpy(timebuf, cf->file_ent->ce_conflict, sizeof(timebuf)); @@ -700,8 +699,7 @@ cvs_client_updated(char *data) time(&now); asctime_r(gmtime(&now), timebuf); - if (timebuf[strlen(timebuf) - 1] == '\n') - timebuf[strlen(timebuf) - 1] = '\0'; + timebuf[strcspn(timebuf, "\n")] = '\0'; e = cvs_ent_parse(en); xfree(en); @@ -790,8 +788,7 @@ cvs_client_merged(char *data) time(&now); asctime_r(gmtime(&now), timebuf); - if (timebuf[strlen(timebuf) - 1] == '\n') - timebuf[strlen(timebuf) - 1] = '\0'; + timebuf[strcspn(timebuf, "\n")] = '\0'; ent = cvs_ent_open(wdir); cvs_ent_add(ent, entry); diff --git a/usr.bin/cvs/edit.c b/usr.bin/cvs/edit.c index 988d4a24ef0..2a95b57703a 100644 --- a/usr.bin/cvs/edit.c +++ b/usr.bin/cvs/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.39 2007/10/05 19:28:23 gilles Exp $ */ +/* $OpenBSD: edit.c,v 1.40 2008/01/10 10:08:22 tobias Exp $ */ /* * Copyright (c) 2006, 2007 Xavier Santolaria <xsa@openbsd.org> * @@ -275,8 +275,7 @@ cvs_edit_local(struct cvs_file *cf) fatal("gmtime failed"); asctime_r(t, timebuf); - if (timebuf[strlen(timebuf) - 1] == '\n') - timebuf[strlen(timebuf) - 1] = '\0'; + timebuf[strcspn(timebuf, "\n")] = '\0'; if (gethostname(thishost, sizeof(thishost)) == -1) fatal("gethostname failed"); @@ -362,8 +361,7 @@ cvs_unedit_local(struct cvs_file *cf) fatal("gmtime failed"); asctime_r(t, timebuf); - if (timebuf[strlen(timebuf) - 1] == '\n') - timebuf[strlen(timebuf) - 1] = '\0'; + timebuf[strcspn(timebuf, "\n")] = '\0'; if (gethostname(thishost, sizeof(thishost)) == -1) fatal("gethostname failed"); @@ -396,8 +394,7 @@ cvs_unedit_local(struct cvs_file *cf) memset(timebuf, 0, sizeof(timebuf)); ctime_r(&cf->file_ent->ce_mtime, timebuf); - if (timebuf[strlen(timebuf) - 1] == '\n') - timebuf[strlen(timebuf) - 1] = '\0'; + timebuf[strcspn(timebuf, "\n")] = '\0'; (void)xasprintf(&entry, "/%s/%s/%s/%s/%s", cf->file_name, rbuf, timebuf, diff --git a/usr.bin/cvs/remove.c b/usr.bin/cvs/remove.c index ac8c773955c..6a0f5625bb3 100644 --- a/usr.bin/cvs/remove.c +++ b/usr.bin/cvs/remove.c @@ -1,4 +1,4 @@ -/* $OpenBSD: remove.c,v 1.66 2007/09/22 16:01:22 joris Exp $ */ +/* $OpenBSD: remove.c,v 1.67 2008/01/10 10:08:22 tobias Exp $ */ /* * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> * @@ -189,8 +189,7 @@ cvs_remove_local(struct cvs_file *cf) sizeof(rbuf)); ctime_r(&cf->file_ent->ce_mtime, tbuf); - if (tbuf[strlen(tbuf) - 1] == '\n') - tbuf[strlen(tbuf) - 1] = '\0'; + tbuf[strcspn(tbuf, "\n")] = '\0'; entry = xmalloc(CVS_ENT_MAXLINELEN); (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c index 9d4bdf31d18..caa1f569459 100644 --- a/usr.bin/cvs/update.c +++ b/usr.bin/cvs/update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: update.c,v 1.112 2007/09/23 11:19:24 joris Exp $ */ +/* $OpenBSD: update.c,v 1.113 2008/01/10 10:08:22 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -426,8 +426,7 @@ update_clear_conflict(struct cvs_file *cf) time(&now); ctime_r(&now, timebuf); - if (timebuf[strlen(timebuf) - 1] == '\n') - timebuf[strlen(timebuf) - 1] = '\0'; + timebuf[strcspn(timebuf, "\n")] = '\0'; rcsnum_tostr(cf->file_ent->ce_rev, revbuf, sizeof(revbuf)); diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c index 10b5b95a180..b3a8c30915f 100644 --- a/usr.bin/cvs/util.c +++ b/usr.bin/cvs/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.122 2008/01/10 10:00:53 tobias Exp $ */ +/* $OpenBSD: util.c,v 1.123 2008/01/10 10:08:22 tobias Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org> @@ -471,7 +471,7 @@ void cvs_get_repository_name(const char *dir, char *dst, size_t len) { FILE *fp; - char *s, fpath[MAXPATHLEN]; + char fpath[MAXPATHLEN]; /* During checkout -p, do not use any locally available files. */ if (cvs_cmdop == CVS_OP_CHECKOUT && print_stdout) { @@ -487,10 +487,7 @@ cvs_get_repository_name(const char *dir, char *dst, size_t len) if (cvs_cmdop != CVS_OP_IMPORT && (fp = fopen(fpath, "r")) != NULL) { if ((fgets(dst, len, fp)) == NULL) fatal("cvs_get_repository_name: bad repository file"); - - if ((s = strchr(dst, '\n')) != NULL) - *s = '\0'; - + dst[strcspn(dst, "\n")] = '\0'; (void)fclose(fp); } else { dst[0] = '\0'; |