mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 19:12:57 +00:00
Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys.
This commit is contained in:
parent
b94e2d8ca0
commit
c2c66aff7d
24198 changed files with 0 additions and 37285 deletions
54
sdk/lib/crt/string/_mbstrnlen.c
Normal file
54
sdk/lib/crt/string/_mbstrnlen.c
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS CRT
|
||||
* PURPOSE: Implementation of _mbstrnlen
|
||||
* FILE: lib/sdk/crt/string/_mbstrnlen.c
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
#include <mbctype.h>
|
||||
#include <specstrings.h>
|
||||
|
||||
_Success_(return>0)
|
||||
_Check_return_
|
||||
_CRTIMP
|
||||
size_t
|
||||
__cdecl
|
||||
_mbstrnlen(
|
||||
_In_z_ const char *pmbstr,
|
||||
_In_ size_t cjMaxLen)
|
||||
{
|
||||
size_t cchCount = 0;
|
||||
unsigned char jMbsByte;
|
||||
|
||||
/* Check parameters */
|
||||
if (!MSVCRT_CHECK_PMT((pmbstr != 0)) && (cjMaxLen <= INT_MAX))
|
||||
{
|
||||
_set_errno(EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
/* if this is a lead byte, continue with next char */
|
||||
if (_ismbblead(jMbsByte))
|
||||
{
|
||||
// FIXME: check if this is a valid char.
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Count this character */
|
||||
cchCount++;
|
||||
}
|
||||
|
||||
return cchCount;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue