strcspn.c 595 B

123456789101112131415161718192021222324252627282930313233
  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 Wstrcspn wcscspn
  10. #else
  11. libc_hidden_proto(strcspn)
  12. # define Wstrcspn strcspn
  13. #endif
  14. size_t Wstrcspn(const Wchar *s1, const Wchar *s2)
  15. {
  16. register const Wchar *s;
  17. register const Wchar *p;
  18. for ( s=s1 ; *s ; s++ ) {
  19. for ( p=s2 ; *p ; p++ ) {
  20. if (*p == *s) goto done;
  21. }
  22. }
  23. done:
  24. return s - s1;
  25. }
  26. #ifndef WANT_WIDE
  27. libc_hidden_def(strcspn)
  28. #endif