diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index 17d585fa1bb..2421011eb5c 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -931,6 +931,33 @@ MSVCRT_size_t _mbsnbcnt(const unsigned char* str, MSVCRT_size_t len) } +/********************************************************************* + * _mbsnbcat(MSVCRT.@) + */ +unsigned char* _mbsnbcat(unsigned char* dst, const unsigned char* src, MSVCRT_size_t len) +{ + if(MSVCRT___mb_cur_max > 1) + { + char *res = dst; + while (*dst) { + if (MSVCRT_isleadbyte(*dst++)) { + if (*dst) { + dst++; + } else { + /* as per msdn overwrite the lead byte in front of '\0' */ + dst--; + break; + } + } + } + while (*src && len--) *dst++ = *src++; + *dst = '\0'; + return res; + } + return strncat(dst, src, len); /* ASCII CP */ +} + + /********************************************************************* * _mbsncat(MSVCRT.@) */ diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index f3d8b3fa6cc..8665ea58aa0 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -359,7 +359,7 @@ @ cdecl _mbsinc(str) _mbsinc @ cdecl _mbslen(str) _mbslen @ cdecl _mbslwr(str) _mbslwr -@ stub _mbsnbcat #(str str long) +@ cdecl _mbsnbcat (str str long) _mbsnbcat @ cdecl _mbsnbcmp(str str long) _mbsnbcmp @ cdecl _mbsnbcnt(ptr long) _mbsnbcnt @ stub _mbsnbcoll #(str str long)