ReactOS 0.4.16-dev-814-g656a5dc
mbccpy_s_l.cpp
Go to the documentation of this file.
1/***
2*mbccpy_s_l.c - Copy one character to another (MBCS)
3*
4* Copyright (c) Microsoft Corporation. All rights reserved.
5*
6*Purpose:
7* Copy one MBCS character to another (1 or 2 bytes)
8*
9*******************************************************************************/
10
13#include <locale.h>
14
15#pragma warning(disable:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED) // 26018
16
17errno_t __cdecl _mbccpy_s_l(unsigned char *_Dst, size_t _SizeInBytes, int *_PCopied, const unsigned char *_Src, _LOCALE_ARG_DECL)
18{
19 /* validation section */
20 _ASSIGN_IF_NOT_NULL(_PCopied, 0);
22 if (_Src == nullptr)
23 {
24 *_Dst = '\0';
26 }
27
29
30 /* copy */
31 if (_ISMBBLEAD(*_Src))
32 {
33 if (_Src[1] == '\0')
34 {
35 /* the source string contained a lead byte followed by the null terminator:
36 we copy only the null terminator and return EILSEQ to indicate the
37 malformed char */
38 *_Dst = '\0';
39 _ASSIGN_IF_NOT_NULL(_PCopied, 1);
41 }
42 if (_SizeInBytes < 2)
43 {
44 *_Dst = '\0';
46 }
47 *_Dst++ = *_Src++;
48 *_Dst = *_Src;
49 _ASSIGN_IF_NOT_NULL(_PCopied, 2);
50 }
51 else
52 {
53 *_Dst = *_Src;
54 _ASSIGN_IF_NOT_NULL(_PCopied, 1);
55 }
56
58}
#define __cdecl
Definition: accygwin.h:79
#define _LOCALE_ARG_DECL
#define _RETURN_EINVAL
#define _ASSIGN_IF_NOT_NULL(_Pointer, _Value)
#define _RETURN_BUFFER_TOO_SMALL(_String, _Size)
#define _RETURN_NO_ERROR
#define _LOCALE_UPDATE
#define _RETURN_MBCS_ERROR
#define _ISMBBLEAD(_Character)
#define _VALIDATE_STRING(_String, _Size)
errno_t __cdecl _mbccpy_s_l(unsigned char *_Dst, size_t _SizeInBytes, int *_PCopied, const unsigned char *_Src, _LOCALE_ARG_DECL)
Definition: mbccpy_s_l.cpp:17
_In_ size_t _SizeInBytes
Definition: time.h:146
int errno_t
Definition: corecrt.h:615