Commit bf9ac906 authored by Bartosz Kosiorek's avatar Bartosz Kosiorek Committed by Alexandre Julliard

msvcrt: Add _mbsnbcpy_l implementation.

parent a6ed3d55
......@@ -1134,7 +1134,7 @@
@ cdecl _mbsnbcoll(str str long)
@ cdecl _mbsnbcoll_l(str str long ptr)
@ cdecl _mbsnbcpy(ptr str long)
@ stub _mbsnbcpy_l
@ cdecl _mbsnbcpy_l(ptr str long ptr)
@ cdecl _mbsnbcpy_s(ptr long str long)
@ cdecl _mbsnbcpy_s_l(ptr long str long ptr)
@ cdecl _mbsnbicmp(str str long)
......
......@@ -1491,7 +1491,7 @@
@ cdecl _mbsnbcoll(str str long)
@ cdecl _mbsnbcoll_l(str str long ptr)
@ cdecl _mbsnbcpy(ptr str long)
@ stub _mbsnbcpy_l
@ cdecl _mbsnbcpy_l(ptr str long ptr)
@ cdecl _mbsnbcpy_s(ptr long str long)
@ cdecl _mbsnbcpy_s_l(ptr long str long ptr)
@ cdecl _mbsnbicmp(str str long)
......
......@@ -1502,7 +1502,7 @@
@ cdecl _mbsnbcoll(str str long)
@ cdecl _mbsnbcoll_l(str str long ptr)
@ cdecl _mbsnbcpy(ptr str long)
@ stub _mbsnbcpy_l
@ cdecl _mbsnbcpy_l(ptr str long ptr)
@ cdecl _mbsnbcpy_s(ptr long str long)
@ cdecl _mbsnbcpy_s_l(ptr long str long ptr)
@ cdecl _mbsnbicmp(str str long)
......
......@@ -806,7 +806,7 @@
@ cdecl _mbsnbcoll(str str long)
@ cdecl _mbsnbcoll_l(str str long ptr)
@ cdecl _mbsnbcpy(ptr str long)
@ stub _mbsnbcpy_l
@ cdecl _mbsnbcpy_l(ptr str long ptr)
@ cdecl _mbsnbcpy_s(ptr long str long)
@ cdecl _mbsnbcpy_s_l(ptr long str long ptr)
@ cdecl _mbsnbicmp(str str long)
......
......@@ -784,7 +784,7 @@
@ cdecl _mbsnbcoll(str str long)
@ cdecl _mbsnbcoll_l(str str long ptr)
@ cdecl _mbsnbcpy(ptr str long)
@ stub _mbsnbcpy_l
@ cdecl _mbsnbcpy_l(ptr str long ptr)
@ cdecl _mbsnbcpy_s(ptr long str long)
@ cdecl _mbsnbcpy_s_l(ptr long str long ptr)
@ cdecl _mbsnbicmp(str str long)
......
......@@ -993,39 +993,58 @@ int CDECL _mbscpy_s(unsigned char *dst, size_t size, const unsigned char *src)
}
/*********************************************************************
* _mbsnbcpy(MSVCRT.@)
* _mbsnbcpy_l(MSVCRT.@)
* REMARKS
* Like strncpy this function doesn't enforce the string to be
* NUL-terminated
*/
unsigned char* CDECL _mbsnbcpy(unsigned char* dst, const unsigned char* src, size_t n)
unsigned char* CDECL _mbsnbcpy_l(unsigned char* dst, const unsigned char* src, size_t n, _locale_t locale)
{
unsigned char* ret = dst;
if(!n)
return dst;
if(get_mbcinfo()->ismbcodepage)
{
BOOL is_lead = FALSE;
while (*src && n)
unsigned char* ret = dst;
pthreadmbcinfo mbcinfo;
if (!n)
return dst;
if (!MSVCRT_CHECK_PMT(dst && src))
return NULL;
if (locale)
mbcinfo = locale->mbcinfo;
else
mbcinfo = get_mbcinfo();
if (mbcinfo->ismbcodepage)
{
is_lead = (!is_lead && _ismbblead(*src));
n--;
*dst++ = *src++;
}
BOOL is_lead = FALSE;
while (*src && n)
{
is_lead = (!is_lead && _ismbblead_l(*src, locale));
n--;
*dst++ = *src++;
}
if (is_lead) /* if string ends with a lead, remove it */
*(dst - 1) = 0;
}
else
{
while (n)
if (is_lead) /* if string ends with a lead, remove it */
*(dst - 1) = 0;
}
else
{
n--;
if (!(*dst++ = *src++)) break;
while (n)
{
n--;
if (!(*dst++ = *src++)) break;
}
}
}
while (n--) *dst++ = 0;
return ret;
while (n--) *dst++ = 0;
return ret;
}
/*********************************************************************
* _mbsnbcpy(MSVCRT.@)
* REMARKS
* Like strncpy this function doesn't enforce the string to be
* NUL-terminated
*/
unsigned char* CDECL _mbsnbcpy(unsigned char* dst, const unsigned char* src, size_t n)
{
return _mbsnbcpy_l(dst, src, n, NULL);
}
/*********************************************************************
......
......@@ -755,7 +755,7 @@
@ cdecl _mbsnbcoll(str str long)
@ cdecl _mbsnbcoll_l(str str long ptr)
@ cdecl _mbsnbcpy(ptr str long)
# stub _mbsnbcpy_l(ptr str long ptr)
@ cdecl _mbsnbcpy_l(ptr str long ptr)
@ cdecl _mbsnbcpy_s(ptr long str long)
@ cdecl _mbsnbcpy_s_l(ptr long str long ptr)
@ cdecl _mbsnbicmp(str str long)
......
......@@ -650,7 +650,7 @@
@ cdecl _mbsnbcoll(str str long)
@ cdecl _mbsnbcoll_l(str str long ptr)
@ cdecl _mbsnbcpy(ptr str long)
@ stub _mbsnbcpy_l
@ cdecl _mbsnbcpy_l(ptr str long ptr)
@ cdecl _mbsnbcpy_s(ptr long str long)
@ cdecl _mbsnbcpy_s_l(ptr long str long ptr)
@ cdecl _mbsnbicmp(str str long)
......@@ -1219,7 +1219,7 @@
@ cdecl _o__mbsnbcoll(str str long) _mbsnbcoll
@ cdecl _o__mbsnbcoll_l(str str long ptr) _mbsnbcoll_l
@ cdecl _o__mbsnbcpy(ptr str long) _mbsnbcpy
@ stub _o__mbsnbcpy_l
@ cdecl _o__mbsnbcpy_l(ptr str long ptr) _mbsnbcpy_l
@ cdecl _o__mbsnbcpy_s(ptr long str long) _mbsnbcpy_s
@ cdecl _o__mbsnbcpy_s_l(ptr long str long ptr) _mbsnbcpy_s_l
@ cdecl _o__mbsnbicmp(str str long) _mbsnbicmp
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment