ReactOS 0.4.16-dev-927-g467dec4
mbsncpy.cpp File Reference
#include <corecrt_internal_mbstring.h>
#include <locale.h>
#include <string.h>
Include dependency graph for mbsncpy.cpp:

Go to the source code of this file.

Functions

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

Function Documentation

◆ _mbsncpy()

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

Definition at line 87 of file mbsncpy.cpp.

92{
94 return _mbsncpy_l(dst, src, cnt, nullptr);
96}
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 _mbsncpy_l(unsigned char *dst, const unsigned char *src, size_t cnt, _locale_t plocinfo)
Definition: mbsncpy.cpp:43
_In_ size_t cnt
Definition: wcstombs.cpp:43

◆ _mbsncpy_l()

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

Definition at line 43 of file mbsncpy.cpp.

49{
50 unsigned char *start = dst;
51 _LocaleUpdate _loc_update(plocinfo);
52
53 /* validation section */
54 _VALIDATE_RETURN(dst != nullptr || cnt == 0, EINVAL, nullptr);
55 _VALIDATE_RETURN(src != nullptr || cnt == 0, EINVAL, nullptr);
56
58 if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
59#pragma warning(suppress:__WARNING_BANNED_API_USAGE)
60 return (unsigned char *)strncpy((char *)dst, (const char *)src, cnt);
62
63 while (cnt) {
64
65 cnt--;
66 if ( _ismbblead_l(*src, _loc_update.GetLocaleT()) ) {
67 *dst++ = *src++;
68 if ((*dst++ = *src++) == '\0') {
69 dst[-2] = '\0';
70 break;
71 }
72 }
73 else
74 if ((*dst++ = *src++) == '\0')
75 break;
76
77 }
78
79 /* pad with nulls as needed */
80
81 while (cnt--)
82 *dst++ = '\0';
83
84#pragma warning(suppress:__WARNING_POSTCONDITION_NULLTERMINATION_VIOLATION) // 26036 REVIEW annotation mistake?
85 return start;
86}
#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 _mbsncpy().