Reactos
1//
2// wcsncat.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// Defines wcsncat(), which appends n characters of the source string onto the
7// end of the destination string. The destination string is always null
8// terminated. Unlike wcsncpy, this function does not pad out to 'count'
9// characters.
10//
11#include <string.h>
12
13
14#pragma warning(disable:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED) // 26018
15
16extern "C" wchar_t* __cdecl wcsncat(
17 wchar_t* const destination,
18 wchar_t const* const source,
19 size_t const count
20 )
21{
22 wchar_t* destination_it = destination;
23
24 // Find the end of the destination string:
25 while (*destination_it)
26 ++destination_it;
27
28 // Append the source string:
29 wchar_t const* source_it = source;
30 for (size_t i = 0; i != count; ++i)
31 {
32 if ((*destination_it++ = *source_it++) == 0)
33 return destination;
34 }
35
36 *destination_it = 0;
37
38 return destination;
39}