ReactOS 0.4.16-dev-959-g2ec3a19
mbsnbcpy.cpp File Reference
#include <corecrt_internal_mbstring.h>
#include <locale.h>
#include <string.h>
Include dependency graph for mbsnbcpy.cpp:

Go to the source code of this file.

Functions

unsigned char *__cdecl _mbsnbcpy_l (unsigned char *dst, const unsigned char *src, size_t cnt, _locale_t plocinfo)
 
unsigned char *__cdecl _mbsnbcpy (unsigned char *dst, const unsigned char *src, size_t cnt)
 

Function Documentation

◆ _mbsnbcpy()

unsigned char *__cdecl _mbsnbcpy ( unsigned char dst,
const unsigned char src,
size_t  cnt 
)

Definition at line 94 of file mbsnbcpy.cpp.

99{
101 return _mbsnbcpy_l(dst, src, cnt, nullptr);
103}
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
#define _END_SECURE_CRT_DEPRECATION_DISABLE
unsigned char *__cdecl _mbsnbcpy_l(unsigned char *dst, const unsigned char *src, size_t cnt, _locale_t plocinfo)
Definition: mbsnbcpy.cpp:43
_In_ size_t cnt
Definition: wcstombs.cpp:43

◆ _mbsnbcpy_l()

unsigned char *__cdecl _mbsnbcpy_l ( unsigned char dst,
const unsigned char src,
size_t  cnt,
_locale_t  plocinfo 
)

Definition at line 43 of file mbsnbcpy.cpp.

49{
50
51 unsigned char *start = dst;
52 _LocaleUpdate _loc_update(plocinfo);
53
54 /* validation section */
55 _VALIDATE_RETURN(dst != nullptr || cnt == 0, EINVAL, nullptr);
56 _VALIDATE_RETURN(src != nullptr || cnt == 0, EINVAL, nullptr);
57
59 if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
60#pragma warning(suppress:__WARNING_BANNED_API_USAGE)
61 return (unsigned char *)strncpy((char *)dst, (const char *)src, cnt);
63
64 while (cnt) {
65
66 cnt--;
67 if ( _ismbblead_l(*src, _loc_update.GetLocaleT()) ) {
68 *dst++ = *src++;
69 if (!cnt) {
70 dst[-1] = '\0';
71 break;
72 }
73 cnt--;
74 if ((*dst++ = *src++) == '\0') {
75 dst[-2] = '\0';
76 break;
77 }
78 }
79
80 else
81 if ((*dst++ = *src++) == '\0')
82 break;
83
84 }
85
86 /* pad with nulls as needed */
87
88 while (cnt--)
89 *dst++ = '\0';
90
91#pragma warning(suppress:__WARNING_POSTCONDITION_NULLTERMINATION_VIOLATION) // 26036
92 return start;
93}
#define EINVAL
Definition: acclib.h:90
#define _ismbblead_l(_c, p)
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
GLuint start
Definition: gl.h:1545
_locale_t plocinfo
Definition: ismbbyte.cpp:75
strncpy
Definition: string.h:335

Referenced by _mbsnbcpy().