ReactOS 0.4.16-dev-959-g2ec3a19
mbslen_s.cpp File Reference
#include <corecrt_internal.h>
#include <corecrt_internal_mbstring.h>
#include <locale.h>
#include <string.h>
Include dependency graph for mbslen_s.cpp:

Go to the source code of this file.

Functions

size_t __cdecl _mbsnlen_l (const unsigned char *s, size_t sizeInBytes, _locale_t plocinfo)
 
size_t __cdecl _mbsnlen (const unsigned char *s, size_t maxsize)
 

Function Documentation

◆ _mbsnlen()

size_t __cdecl _mbsnlen ( const unsigned char s,
size_t  maxsize 
)

Definition at line 78 of file mbslen_s.cpp.

82{
83 return _mbsnlen_l(s,maxsize, nullptr);
84}
GLdouble s
Definition: gl.h:2039
size_t __cdecl _mbsnlen_l(const unsigned char *s, size_t sizeInBytes, _locale_t plocinfo)
Definition: mbslen_s.cpp:42
_In_ size_t const maxsize
Definition: strftime.cpp:120

◆ _mbsnlen_l()

size_t __cdecl _mbsnlen_l ( const unsigned char s,
size_t  sizeInBytes,
_locale_t  plocinfo 
)

Definition at line 42 of file mbslen_s.cpp.

47{
48 size_t n, size;
49 _LocaleUpdate _loc_update(plocinfo);
50
51 if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
52 return strnlen((const char *)s, sizeInBytes);
53
54 /* Note that we do not check if s == nullptr, because we do not
55 * return errno_t...
56 */
57
58 /* Note that sizeInBytes here is the number of bytes, not mb characters! */
59 for (n = 0, size = 0; size < sizeInBytes && *s; n++, s++, size++)
60 {
61 if ( _ismbblead_l(*s, _loc_update.GetLocaleT()) )
62 {
63 size++;
64 if (size >= sizeInBytes)
65 {
66 break;
67 }
68 if (*++s == '\0')
69 {
70 break;
71 }
72 }
73 }
74
75 return (size >= sizeInBytes ? sizeInBytes : n);
76}
#define _ismbblead_l(_c, p)
GLdouble n
Definition: glext.h:7729
GLsizeiptr size
Definition: glext.h:5919
_locale_t plocinfo
Definition: ismbbyte.cpp:75
size_t sizeInBytes
Definition: mbslwr.cpp:119
size_t __cdecl strnlen(char const *const string, size_t const maximum_count)
Definition: strnlen.cpp:202

Referenced by _mbsnlen().