| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #include <corecrt_internal.h>
|
| #include <ctype.h>
|
| #include <corecrt_internal_securecrt.h>
|
| #include <limits.h>
|
| #include <locale.h>
|
| #include <string.h>
|
|
|
| #pragma warning(disable:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED)
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| extern "C" char * __cdecl _strupr_l (
|
| char * string,
|
| _locale_t plocinfo
|
| )
|
| {
|
| _strupr_s_l(string, (size_t)(-1), plocinfo);
|
| return (string);
|
| }
|
|
|
| extern "C" char * __cdecl _strupr (
|
| char * string
|
| )
|
| {
|
| if (!__acrt_locale_changed())
|
| {
|
|
|
| _VALIDATE_RETURN(string != nullptr, EINVAL, nullptr);
|
|
|
| char *cp;
|
|
|
| for ( cp = string ; *cp ; ++cp )
|
| if ( ('a' <= *cp) && (*cp <= 'z') )
|
| *cp -= 'a' - 'A';
|
|
|
| return(string);
|
| }
|
| else
|
| {
|
| _strupr_s_l(string, (size_t)(-1), nullptr);
|
| return (string);
|
| }
|
| }
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| static errno_t __cdecl _strupr_s_l_stat (
|
| _Inout_updates_z_(sizeInBytes) char * const string,
|
| size_t const sizeInBytes,
|
| _locale_t const plocinfo
|
| ) throw()
|
| {
|
| int dstsize;
|
| size_t stringlen;
|
|
|
|
|
| _VALIDATE_RETURN_ERRCODE(string != nullptr, EINVAL);
|
| stringlen = strnlen(string, sizeInBytes);
|
| if (stringlen >= sizeInBytes)
|
| {
|
| _RESET_STRING(string, sizeInBytes);
|
| _RETURN_DEST_NOT_NULL_TERMINATED(string, sizeInBytes);
|
| }
|
| _FILL_STRING(string, sizeInBytes, stringlen + 1);
|
|
|
| if ( plocinfo->locinfo->locale_name[LC_CTYPE] == nullptr )
|
| {
|
| char *cp=string;
|
|
|
| for ( ; *cp ; ++cp )
|
| {
|
| if ( ('a' <= *cp) && (*cp <= 'z') )
|
| {
|
| *cp -= 'a' - 'A';
|
| }
|
| }
|
|
|
| return 0;
|
| }
|
|
|
|
|
| if ( 0 == (dstsize = __acrt_LCMapStringA(
|
| plocinfo,
|
| plocinfo->locinfo->locale_name[LC_CTYPE],
|
| LCMAP_UPPERCASE,
|
| string,
|
| -1,
|
| nullptr,
|
| 0,
|
| plocinfo->locinfo->_public._locale_lc_codepage,
|
| TRUE )) )
|
| {
|
| errno = EILSEQ;
|
| return errno;
|
| }
|
|
|
| if (sizeInBytes < (size_t)dstsize)
|
| {
|
| _RESET_STRING(string, sizeInBytes);
|
| _RETURN_BUFFER_TOO_SMALL(string, sizeInBytes);
|
| }
|
|
|
|
|
| __crt_scoped_stack_ptr<char> const dst(_malloca_crt_t(char, dstsize));
|
| if (!dst)
|
| {
|
| errno = ENOMEM;
|
| return errno;
|
| }
|
|
|
|
|
| if (__acrt_LCMapStringA(
|
| plocinfo,
|
| plocinfo->locinfo->locale_name[LC_CTYPE],
|
| LCMAP_UPPERCASE,
|
| string,
|
| -1,
|
| dst.get(),
|
| dstsize,
|
| plocinfo->locinfo->_public._locale_lc_codepage,
|
| TRUE ) != 0)
|
| {
|
|
|
| return strcpy_s(string, sizeInBytes, dst.get());
|
| }
|
| else
|
| {
|
| return errno = EILSEQ;
|
| }
|
| }
|
|
|
| extern "C" errno_t __cdecl _strupr_s_l (
|
| char * string,
|
| size_t sizeInBytes,
|
| _locale_t plocinfo
|
| )
|
| {
|
| _LocaleUpdate _loc_update(plocinfo);
|
|
|
| return _strupr_s_l_stat(string, sizeInBytes, _loc_update.GetLocaleT());
|
| }
|
|
|
| extern "C" errno_t __cdecl _strupr_s (
|
| char * string,
|
| size_t sizeInBytes
|
| )
|
| {
|
| return _strupr_s_l(string, sizeInBytes, nullptr);
|
| }
|
|
|