summaryrefslogtreecommitdiff
path: root/lib/libc/gen/getcap.c
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2006-03-22 02:42:12 +0000
committerRay Lai <ray@cvs.openbsd.org>2006-03-22 02:42:12 +0000
commitfd9f7b23f23239b2b457cc7b9cc9182529bb151f (patch)
treefd7850424587853fcb7232353690c9e24f1ce144 /lib/libc/gen/getcap.c
parentc41c1eb74663f6c14a99ce348b1ac201e18cb5f9 (diff)
Simplify cgetnext(3) by using strcspn(3).
OK jaredy@ and otto@
Diffstat (limited to 'lib/libc/gen/getcap.c')
-rw-r--r--lib/libc/gen/getcap.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c
index 3ef6b0d5f03..746593f83fe 100644
--- a/lib/libc/gen/getcap.c
+++ b/lib/libc/gen/getcap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getcap.c,v 1.25 2006/03/18 03:55:09 ray Exp $ */
+/* $OpenBSD: getcap.c,v 1.26 2006/03/22 02:42:11 ray Exp $ */
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -659,7 +659,7 @@ cgetnext(char **bp, char **db_array)
{
size_t len;
int status, done;
- char *cp, *line, *np, buf[BSIZE], nbuf[BSIZE];
+ char *line, *np, buf[BSIZE], nbuf[BSIZE];
u_int dummy;
if (dbp == NULL)
@@ -719,17 +719,12 @@ cgetnext(char **bp, char **db_array)
done = 0;
np = nbuf;
for (;;) {
- for (cp = line; *cp != '\0'; cp++) {
- if (*cp == ':') {
- done = 1;
- cp++;
- break;
- }
- if (*cp == '\\')
- break;
+ len = strcspn(line, ":\\");
+ if (line[len] == ':') {
+ done = 1;
+ ++len;
}
/* copy substring */
- len = cp - line;
if (len >= sizeof(nbuf) - (np - nbuf)) {
(void)cgetclose();
return (-1);