strncat.c 658 B

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