strcspn.c 639 B

1234567891011121314151617181920212223242526272829303132
  1. /* strcspn.c */
  2. /* from Schumacher's Atari library, improved */
  3. #include <string.h>
  4. size_t strcspn(string, set)
  5. register char *string;
  6. char *set;
  7. /*
  8. * Return the length of the sub-string of <string> that consists
  9. * entirely of characters not found in <set>. The terminating '\0'
  10. * in <set> is not considered part of the match set. If the first
  11. * character if <string> is in <set>, 0 is returned.
  12. */
  13. {
  14. register char *setptr;
  15. char *start;
  16. start = string;
  17. while (*string)
  18. {
  19. setptr = set;
  20. do
  21. if (*setptr == *string)
  22. goto break2;
  23. while (*setptr++);
  24. ++string;
  25. }
  26. break2:
  27. return string - start;
  28. }