host_strcspn.c 360 B

1234567891011121314151617181920
  1. /*
  2. * strcspn-like wrapper around host_strchr_internal.
  3. */
  4. #include <stdbool.h>
  5. #include <string.h>
  6. #include "defs.h"
  7. #include "misc.h"
  8. #include "utils/utils.h"
  9. size_t host_strcspn(const char *s, const char *set)
  10. {
  11. const char *answer = host_strchr_internal(s, set, true);
  12. if (answer)
  13. return answer - s;
  14. else
  15. return strlen(s);
  16. }