strnlen.c 484 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 __USE_GNU
  9. #ifdef WANT_WIDE
  10. # define Wstrnlen wcsnlen
  11. #else
  12. # define Wstrnlen strnlen
  13. #endif
  14. size_t Wstrnlen(const Wchar *s, size_t max)
  15. {
  16. register const Wchar *p = s;
  17. while (max && *p) {
  18. ++p;
  19. --max;
  20. }
  21. return p - s;
  22. }
  23. libc_hidden_def(Wstrnlen)
  24. #endif