projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
don't truncate lines, don't allow tabs to back up (I think this is tested!)
[unix-history]
/
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
b13e2b8
..
f454319
100644
(file)
--- 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 <sys/stdc.h>
+#include <string.h>
-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
);
}
}