Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.5 KiB

  1. /***
  2. *wcsncat.c - append n chars of string to new string
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines wcsncat() - appends n characters of string onto
  8. * end of other string
  9. *
  10. *Revision History:
  11. * 09-09-91 ETC Created from strncat.c.
  12. * 04-07-92 KRS Updated and ripped out _INTL switches.
  13. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  14. * 02-07-94 CFW POSIXify.
  15. *
  16. *******************************************************************************/
  17. #ifndef _POSIX_
  18. #include <cruntime.h>
  19. #include <string.h>
  20. /***
  21. *wchar_t *wcsncat(front, back, count) - append count chars of back onto front
  22. *
  23. *Purpose:
  24. * Appends at most count characters of the string back onto the
  25. * end of front, and ALWAYS terminates with a null character.
  26. * If count is greater than the length of back, the length of back
  27. * is used instead. (Unlike wcsncpy, this routine does not pad out
  28. * to count characters).
  29. *
  30. *Entry:
  31. * wchar_t *front - string to append onto
  32. * wchar_t *back - string to append
  33. * size_t count - count of max characters to append
  34. *
  35. *Exit:
  36. * returns a pointer to string appended onto (front).
  37. *
  38. *Uses:
  39. *
  40. *Exceptions:
  41. *
  42. *******************************************************************************/
  43. wchar_t * __cdecl wcsncat (
  44. wchar_t * front,
  45. const wchar_t * back,
  46. size_t count
  47. )
  48. {
  49. wchar_t *start = front;
  50. while (*front++)
  51. ;
  52. front--;
  53. while (count--)
  54. if (!(*front++ = *back++))
  55. return(start);
  56. *front = L'\0';
  57. return(start);
  58. }
  59. #endif /* _POSIX_ */