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

Go to the source code of this file.

Functions

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

Function Documentation

◆ _mbsncat()

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

Definition at line 101 of file mbsncat.cpp.

106{
108 return _mbsncat_l(dst, src, cnt, nullptr);
110}
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 _mbsncat_l(unsigned char *dst, const unsigned char *src, size_t cnt, _locale_t plocinfo)
Definition: mbsncat.cpp:38
_In_ size_t cnt
Definition: wcstombs.cpp:43

◆ _mbsncat_l()

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

Definition at line 38 of file mbsncat.cpp.

44{
45 unsigned char *start;
46
47 if (!cnt)
48 return(dst);
49
50 /* validation section */
51 _VALIDATE_RETURN(dst != nullptr, EINVAL, nullptr);
52 _VALIDATE_RETURN(src != nullptr, EINVAL, nullptr);
53
54 _LocaleUpdate _loc_update(plocinfo);
55
57 if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
58 return (unsigned char *)strncat((char *)dst, (const char *)src, cnt);
60
61 start = dst;
62 while (*dst++)
63 ;
64 --dst; // dst now points to end of dst string
65
66
67 /* if last char in string is a lead byte, back up pointer */
68
69 if ( _ismbslead_l(start, dst, _loc_update.GetLocaleT()) )
70 --dst;
71
72 /* copy over the characters */
73
74 while (cnt--) {
75 if ( _ismbblead_l(*src, _loc_update.GetLocaleT()) ) {
76 *dst++ = *src++;
77 if ((*dst++ = *src++) == '\0') {
78 dst[-2] = '\0';
79 break;
80 }
81 }
82
83 else if ((*dst++ = *src++) == '\0')
84 break;
85
86 }
87
88 /* enter final nul, if necessary */
89 if ( dst!=start && _mbsbtype_l(start, (int) ((dst - start) - 1), _loc_update.GetLocaleT()) == _MBC_LEAD )
90 {
91 dst[-1] = '\0';
92 }
93 else
94 {
95 *dst = '\0';
96 }
97
98 return(start);
99}
#define EINVAL
Definition: acclib.h:90
#define _ismbblead_l(_c, p)
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
_Check_return_ _CRTIMP int __cdecl _ismbslead_l(_In_reads_z_(_Pos - _Str+1) const unsigned char *_Str, _In_z_ const unsigned char *_Pos, _In_opt_ _locale_t _Locale)
GLuint start
Definition: gl.h:1545
_CRTIMP int __cdecl _mbsbtype_l(_In_reads_bytes_(_Pos) _Pre_z_ const unsigned char *_Str, _In_ size_t _Pos, _In_opt_ _locale_t _Locale)
_locale_t plocinfo
Definition: ismbbyte.cpp:75
#define _MBC_LEAD
Definition: msvcrt.h:824
_In_opt_ _Locale strncat
Definition: string.h:263

Referenced by _mbsncat().