strncat.c 565 B

12345678910111213141516171819202122232425262728293031323334
  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 Wstrncat wcsncat
  10. #else
  11. # define Wstrncat strncat
  12. #endif
  13. Wchar *Wstrncat(Wchar * __restrict s1, register const Wchar * __restrict s2,
  14. size_t n)
  15. {
  16. register Wchar *s = s1;
  17. while (*s++);
  18. --s;
  19. while (n && ((*s = *s2++) != 0)) {
  20. --n;
  21. ++s;
  22. }
  23. *s = 0;
  24. return s1;
  25. }
  26. #ifndef WANT_WIDE
  27. libc_hidden_def(strncat)
  28. #endif