From 909ffb7930d244e76640998045521626476dc28e Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Fri, 14 Feb 2003 23:26:58 +0000 Subject: [PATCH] Implemented _mbsnbcat. --- dlls/msvcrt/mbcs.c | 27 +++++++++++++++++++++++++++ dlls/msvcrt/msvcrt.spec | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) 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)