diff options
| author | 2006-03-22 02:42:11 +0000 | |
|---|---|---|
| committer | 2006-03-22 02:42:11 +0000 | |
| commit | 50067d8e8e2e02550dc305597df1dfe1433ac877 (patch) | |
| tree | a7ed1f5adb124da7b2102c22006baa2a9b43e356 | |
| parent | Add pci_find_device() a helper function for enumerating the (diff) | |
| download | wireguard-openbsd-50067d8e8e2e02550dc305597df1dfe1433ac877.tar.xz wireguard-openbsd-50067d8e8e2e02550dc305597df1dfe1433ac877.zip | |
Simplify cgetnext(3) by using strcspn(3).
OK jaredy@ and otto@
| -rw-r--r-- | lib/libc/gen/getcap.c | 17 |
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); |
