X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/413c649ff21f9b30e1fac23005ac37594b4cd628..fdb8e4aac282b72d4670aa3a26d9bba07afc7e6f:/usr/src/lib/libc/string/strspn.c diff --git a/usr/src/lib/libc/string/strspn.c b/usr/src/lib/libc/string/strspn.c index b13e2b8c1b..f454319fab 100644 --- a/usr/src/lib/libc/string/strspn.c +++ b/usr/src/lib/libc/string/strspn.c @@ -1,31 +1,35 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. The Berkeley software License Agreement - * specifies the terms and conditions for redistribution. + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * %sccs.include.redist.c% */ -/* - * Sys5 compat routine - */ +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strspn.c 5.7 (Berkeley) %G%"; +#endif /* LIBC_SCCS and not lint */ -#ifndef lint -static char sccsid[] = "@(#)strspn.c 5.1 (Berkeley) 85/08/05"; -#endif +#include +#include -strspn(s, set) - register char *s, *set; +/* + * Span the string s2 (skip characters that are in s2). + */ +size_t +strspn(s1, s2) + const char *s1; + register const char *s2; { - register n = 0; - register char *p; - register c; + register const char *p = s1, *spanp; + register char c, sc; - while (c = *s++) { - for (p = set; *p; p++) - if (c == *p) - break; - if (!*p) - return (n); - n++; - } - return (n); + /* + * Skip any characters in s2, excluding the terminating \0. + */ +cont: + c = *p++; + for (spanp = s2; (sc = *spanp++) != 0;) + if (sc == c) + goto cont; + return (p - 1 - s1); }