home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / compiler / clib / strspn.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-09  |  1.1 KB  |  66 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: strspn.c,v 1.1 1996/12/11 11:18:28 aros Exp $
  4.  
  5.     Desc: ANSI C function strspn()
  6.     Lang: english
  7. */
  8.  
  9. /*****************************************************************************
  10.  
  11.     NAME */
  12. #include <string.h>
  13.  
  14.     size_t strspn (
  15.  
  16. /*  SYNOPSIS */
  17.     const char * str,
  18.     const char * accept)
  19.  
  20. /*  FUNCTION
  21.     Calculates the length of the initial segment of str which consists
  22.     entirely of characters in accept.
  23.  
  24.     INPUTS
  25.     str - The string to check.
  26.     reject - Characters which must not be in str.
  27.  
  28.     RESULT
  29.     Length of the initial segment of str which contains only
  30.     characters from accept.
  31.  
  32.     NOTES
  33.  
  34.     EXAMPLE
  35.     char buffer[64];
  36.  
  37.     strcpy (buffer, "Hello ");
  38.  
  39.     // Returns 5
  40.     strspn (buffer, "Helo");
  41.  
  42.     // Returns 0
  43.     strspn (buffer, "xyz");
  44.  
  45.     BUGS
  46.  
  47.     SEE ALSO
  48.  
  49.     INTERNALS
  50.  
  51.     HISTORY
  52.     11.12.1996 digulla created
  53.  
  54. ******************************************************************************/
  55. {
  56.     size_t n;
  57.  
  58.     while (*str && strchr (accept, *str))
  59.     {
  60.     str ++;
  61.     n ++;
  62.     }
  63.  
  64.     return n;
  65. } /* strspn */
  66.