reactos/lib/sdk/crt/string/_mbsnlen.c
Amine Khaldi 527f2f9057 [SHELL/EXPERIMENTS]
* Create a branch for some evul shell experiments.

svn path=/branches/shell-experiments/; revision=61927
2014-02-02 19:37:27 +00:00

36 lines
761 B
C

/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS CRT
* PURPOSE: Implementation of _mbsnlen
* FILE: lib/sdk/crt/string/_mbsnlen.c
* PROGRAMMER: Timo Kreuzer
*/
#include <mbstring.h>
_Check_return_
_CRTIMP
size_t
__cdecl
_mbsnlen(
_In_z_ const unsigned char *pmbstr,
_In_ size_t cjMaxLen)
{
size_t cchCount = 0;
unsigned char jMbsByte;
/* Loop while we have bytes to process */
while (cjMaxLen-- > 0)
{
/* Get next mb byte */
jMbsByte = *pmbstr++;
/* If this is 0, we're done */
if (jMbsByte == 0) break;
/* Don't count lead bytes */
if (!_ismbblead(jMbsByte)) cchCount++;
}
return cchCount;
}