mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 00:12:57 +00:00
[UCRT] Import Microsoft.Windows.SDK.CRTSource version 10.0.22621.3
Imported from https://www.nuget.org/packages/Microsoft.Windows.SDK.CRTSource/10.0.22621.3 License: MIT
This commit is contained in:
parent
f1b60c66f0
commit
04e0dc4a7a
568 changed files with 115483 additions and 0 deletions
84
sdk/lib/ucrt/mbstring/mbschr.cpp
Normal file
84
sdk/lib/ucrt/mbstring/mbschr.cpp
Normal file
|
@ -0,0 +1,84 @@
|
|||
/***
|
||||
* mbschr.c - Search MBCS string for character
|
||||
*
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
*
|
||||
*Purpose:
|
||||
* Search MBCS string for a character
|
||||
*
|
||||
*******************************************************************************/
|
||||
#ifndef _MBCS
|
||||
#error This file should only be compiled with _MBCS defined
|
||||
#endif
|
||||
|
||||
#include <corecrt_internal_mbstring.h>
|
||||
#include <locale.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#pragma warning(disable:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED) // 26018
|
||||
|
||||
/***
|
||||
* _mbschr - Search MBCS string for character
|
||||
*
|
||||
*Purpose:
|
||||
* Search the given string for the specified character.
|
||||
* MBCS characters are handled correctly.
|
||||
*
|
||||
*Entry:
|
||||
* unsigned char *string = string to search
|
||||
* int c = character to search for
|
||||
*
|
||||
*Exit:
|
||||
* returns a pointer to the first occurence of the specified char
|
||||
* within the string.
|
||||
*
|
||||
* returns nullptr if the character is not found n the string.
|
||||
*
|
||||
*Exceptions:
|
||||
* Input parameters are validated. Refer to the validation section of the function.
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
extern "C" _CONST_RETURN unsigned char * __cdecl _mbschr_l(
|
||||
const unsigned char *string,
|
||||
unsigned int c,
|
||||
_locale_t plocinfo
|
||||
)
|
||||
{
|
||||
unsigned short cc = '\0';
|
||||
_LocaleUpdate _loc_update(plocinfo);
|
||||
|
||||
/* validation section */
|
||||
_VALIDATE_RETURN(string != nullptr, EINVAL, nullptr);
|
||||
|
||||
if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
|
||||
return (_CONST_RETURN unsigned char *)strchr((const char *)string, (int)c);
|
||||
|
||||
for (; (cc = *string) != '\0'; string++)
|
||||
{
|
||||
if ( _ismbblead_l(cc, _loc_update.GetLocaleT()) )
|
||||
{
|
||||
if (*++string == '\0')
|
||||
return nullptr; /* error */
|
||||
if ( c == (unsigned int)((cc << 8) | *string) ) /* DBCS match */
|
||||
return (unsigned char *)(string - 1);
|
||||
}
|
||||
else if (c == (unsigned int)cc)
|
||||
break; /* SBCS match */
|
||||
}
|
||||
|
||||
if (c == (unsigned int)cc) /* check for SBCS match--handles NUL char */
|
||||
return (unsigned char *)(string);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
extern "C" _CONST_RETURN unsigned char * (__cdecl _mbschr)(
|
||||
const unsigned char *string,
|
||||
unsigned int c
|
||||
)
|
||||
{
|
||||
return _mbschr_l(string, c, nullptr);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue