home *** CD-ROM | disk | FTP | other *** search
- /*
- (C) 1995-96 AROS - The Amiga Replacement OS
- $Id: strspn.c,v 1.1 1996/12/11 11:18:28 aros Exp $
-
- Desc: ANSI C function strspn()
- Lang: english
- */
-
- /*****************************************************************************
-
- NAME */
- #include <string.h>
-
- size_t strspn (
-
- /* SYNOPSIS */
- const char * str,
- const char * accept)
-
- /* FUNCTION
- Calculates the length of the initial segment of str which consists
- entirely of characters in accept.
-
- INPUTS
- str - The string to check.
- reject - Characters which must not be in str.
-
- RESULT
- Length of the initial segment of str which contains only
- characters from accept.
-
- NOTES
-
- EXAMPLE
- char buffer[64];
-
- strcpy (buffer, "Hello ");
-
- // Returns 5
- strspn (buffer, "Helo");
-
- // Returns 0
- strspn (buffer, "xyz");
-
- BUGS
-
- SEE ALSO
-
- INTERNALS
-
- HISTORY
- 11.12.1996 digulla created
-
- ******************************************************************************/
- {
- size_t n;
-
- while (*str && strchr (accept, *str))
- {
- str ++;
- n ++;
- }
-
- return n;
- } /* strspn */
-