home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 316 / libsrc / strcspn.c < prev    next >
Encoding:
Text File  |  1988-10-20  |  492 b   |  26 lines

  1. /*
  2.  * strcspn - find length of initial segment of s1 consisting entirely
  3.  * of characters not from s2
  4.  *
  5.  *  Taken from Henry Spencer's PD version of regexp.
  6.  */
  7.  
  8. int
  9. strcspn(s1, s2)
  10.     char    *s1;
  11.     char    *s2;
  12. {
  13.     register char *scan1;
  14.     register char *scan2;
  15.     register int count;
  16.  
  17.     count = 0;
  18.     for (scan1 = s1; *scan1 != '\0'; scan1++) {
  19.         for (scan2 = s2; *scan2 != '\0';)    /* ++ moved down. */
  20.             if (*scan1 == *scan2++)
  21.                 return(count);
  22.         count++;
  23.     }
  24.     return(count);
  25. }
  26.