strspn.c 538 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (C) 2002 Manuel Novoa III
  3. * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
  4. *
  5. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  6. */
  7. #include "_string.h"
  8. #ifdef WANT_WIDE
  9. # define Wstrspn wcsspn
  10. #else
  11. # define Wstrspn strspn
  12. #endif
  13. libc_hidden_proto(Wstrspn)
  14. size_t Wstrspn(const Wchar *s1, const Wchar *s2)
  15. {
  16. register const Wchar *s = s1;
  17. register const Wchar *p = s2;
  18. while (*p) {
  19. if (*p++ == *s) {
  20. ++s;
  21. p = s2;
  22. }
  23. }
  24. return s - s1;
  25. }
  26. libc_hidden_def(Wstrspn)