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.

57 lines
1.4 KiB

  1. /***
  2. *wcsncpy.c - copy at most n characters of wide-character string
  3. *
  4. * Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines wcsncpy() - copy at most n characters of wchar_t string
  8. *
  9. *Revision History:
  10. * 09-09-91 ETC Created from strncpy.c.
  11. * 04-07-92 KRS Updated and ripped out _INTL switches.
  12. *
  13. *******************************************************************************/
  14. #include <cruntime.h>
  15. #include <string.h>
  16. /***
  17. *wchar_t *wcsncpy(dest, source, count) - copy at most n wide characters
  18. *
  19. *Purpose:
  20. * Copies count characters from the source string to the
  21. * destination. If count is less than the length of source,
  22. * NO NULL CHARACTER is put onto the end of the copied string.
  23. * If count is greater than the length of sources, dest is padded
  24. * with null characters to length count (wide-characters).
  25. *
  26. *
  27. *Entry:
  28. * wchar_t *dest - pointer to destination
  29. * wchar_t *source - source string for copy
  30. * size_t count - max number of characters to copy
  31. *
  32. *Exit:
  33. * returns dest
  34. *
  35. *Exceptions:
  36. *
  37. *******************************************************************************/
  38. wchar_t * _CALLTYPE1 wcsncpy (
  39. wchar_t * dest,
  40. const wchar_t * source,
  41. size_t count
  42. )
  43. {
  44. wchar_t *start = dest;
  45. while (count && (*dest++ = *source++)) /* copy string */
  46. count--;
  47. if (count) /* pad out with zeroes */
  48. while (--count)
  49. *dest++ = L'\0';
  50. return(start);
  51. }