ReactOS 0.4.16-dev-963-g182f353
tolower_toupper.cpp File Reference
#include <corecrt_internal.h>
#include <ctype.h>
#include <locale.h>
#include <stdio.h>
Include dependency graph for tolower_toupper.cpp:

Go to the source code of this file.

Typedefs

typedef unsigned char(__cdecl internal_map_type) (unsigned char
 
typedef unsigned _locale_t
 

Functions

static __forceinline int __cdecl common_tox_win_lookup (int const c, DWORD const map_flag, _locale_t const locale) throw ()
 
template<internal_map_type & MapType>
static __forceinline int __cdecl common_tox_l (int const c, DWORD const map_flag, _locale_t const locale) throw ()
 
int __cdecl _tolower_l (int const c, _locale_t const locale)
 
int __cdecl tolower (int const c)
 
 int (__cdecl _tolower)(int const c)
 
int __cdecl _toupper_l (int const c, _locale_t const locale)
 
int __cdecl toupper (int const c)
 

Typedef Documentation

◆ _locale_t

Definition at line 15 of file tolower_toupper.cpp.

◆ char

typedef unsigned char(__cdecl internal_map_type)(unsigned char

Definition at line 15 of file tolower_toupper.cpp.

Function Documentation

◆ _tolower_l()

int __cdecl _tolower_l ( int const  c,
_locale_t const  locale 
)

Definition at line 83 of file tolower_toupper.cpp.

84{
85 return common_tox_l<_tolower_fast_internal>(c, LCMAP_LOWERCASE, locale);
86}
Definition: _locale.h:75
const GLubyte * c
Definition: glext.h:8905
#define LCMAP_LOWERCASE
Definition: winnls.h:186

Referenced by tolower().

◆ _toupper_l()

int __cdecl _toupper_l ( int const  c,
_locale_t const  locale 
)

Definition at line 102 of file tolower_toupper.cpp.

103{
104 return common_tox_l<_toupper_fast_internal>(c, LCMAP_UPPERCASE, locale);
105}
#define LCMAP_UPPERCASE
Definition: winnls.h:187

Referenced by toupper().

◆ common_tox_l()

template<internal_map_type & MapType>
static __forceinline int __cdecl common_tox_l ( int const  c,
DWORD const  map_flag,
_locale_t const  locale 
)
throw (
)
static

Definition at line 66 of file tolower_toupper.cpp.

67{
68 if (c == EOF)
69 {
70 return EOF;
71 }
72
73 _LocaleUpdate locale_update(locale);
74
75 if (static_cast<unsigned>(c) < 256)
76 {
77 return MapType(static_cast<unsigned char>(c), locale_update.GetLocaleT());
78 }
79
80 return common_tox_win_lookup(c, map_flag, locale_update.GetLocaleT());
81}
#define EOF
Definition: stdio.h:24
static __forceinline int __cdecl common_tox_win_lookup(int const c, DWORD const map_flag, _locale_t const locale)

◆ common_tox_win_lookup()

static __forceinline int __cdecl common_tox_win_lookup ( int const  c,
DWORD const  map_flag,
_locale_t const  locale 
)
throw (
)
static

Definition at line 17 of file tolower_toupper.cpp.

18{
19 // Convert the character to a multibyte string:
20 size_t in_count {};
21 unsigned char in_buffer[3]{};
22 if (locale->locinfo->_public._locale_mb_cur_max > 1 && _isleadbyte_fast_internal(c >> 8 & 0xff, locale))
23 {
24 in_buffer[0] = c >> 8 & 0xff; // Put the lead byte at start of the string
25 in_buffer[1] = static_cast<unsigned char>(c);
26 in_buffer[2] = 0;
27 in_count = 2;
28 }
29 else
30 {
31 // This is undefined behavior: should probably use the wide form instead
32 errno = EILSEQ;
33 in_buffer[0] = static_cast<unsigned char>(c);
34 in_buffer[1] = 0;
35 in_count = 1;
36 }
37
38 // Convert the wide character equivalent to the target case:
39 unsigned char out_buffer[3]{};
41 locale,
42 locale->locinfo->locale_name[LC_CTYPE],
43 map_flag,
44 reinterpret_cast<char const*>(in_buffer),
45 static_cast<int>(in_count),
46 reinterpret_cast<char*>(out_buffer),
47 static_cast<int>(_countof(out_buffer)),
48 locale->locinfo->_public._locale_lc_codepage,
49 TRUE);
50
51 if (out_count == 0)
52 {
53 return c;
54 }
55
56 // Form the integer return value:
57 if (out_count == 1)
58 {
59 return static_cast<int>(out_buffer[0]);
60 }
61
62 return static_cast<int>(out_buffer[1]) | (static_cast<int>(out_buffer[0]) << 8);
63}
int __cdecl __acrt_LCMapStringA(_locale_t const plocinfo, PCWSTR const LocaleName, DWORD const dwMapFlags, PCCH const lpSrcStr, int const cchSrc, PCH const lpDestStr, int const cchDest, int const code_page, BOOL const bError)
_Check_return_ __forceinline unsigned short __cdecl _isleadbyte_fast_internal(_In_ unsigned char const c, _In_ _locale_t const locale)
#define TRUE
Definition: types.h:120
static unsigned char * in_buffer
Definition: iccvid.c:87
#define LC_CTYPE
Definition: locale.h:19
#define c
Definition: ke_i.h:80
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID out_buffer
Definition: file.c:100
static UINT UINT * out_count
Definition: clipboard.c:35
#define errno
Definition: errno.h:18
#define EILSEQ
Definition: errno.h:109
#define _countof(array)
Definition: sndvol32.h:70
#define const
Definition: zconf.h:233

Referenced by common_tox_l().

◆ int()

int ( __cdecl  _tolower) const

Definition at line 95 of file tolower_toupper.cpp.

96{
97 return c - 'A' + 'a';
98}

◆ tolower()

◆ toupper()

int __cdecl toupper ( int const  c)

Definition at line 107 of file tolower_toupper.cpp.

108{
109 return __acrt_locale_changed()
110 ? _toupper_l(c, nullptr)
112}
__forceinline int __CRTDECL __ascii_toupper(int const _C)
Definition: ctype.h:161
int __cdecl _toupper_l(int const c, _locale_t const locale)

Referenced by _getdiskfree(), _ILCreateDrive(), _Locale_toupper(), _main(), _mbbtoupper(), _mbsicmp(), _mbsicoll(), _mbsupr(), _memicmp(), _stricmp(), _strnicmp(), _strupr(), _Success_(), AcpiNsBuildInternalName(), AcpiNsRepair_HID(), AcpiUtStrupr(), Addhost(), change_section_attribs(), Close(), ConvertPathCase(), DliHook(), DosIfCharYesNo(), DosToUpper(), DosToUpperStrN(), DosToUpperStrZ(), EtfspCompareNames(), ExceptionFilter(), FD31_WMInitDialog(), file_cvt(), find_str(), Format(), getbyte(), GetExpandedNameA(), getVKNum(), InteractiveConsole(), FileTypeManager::is_exe_file(), iso9660_file_length(), KdbSymInit(), Link(), main(), MCICDA_Open(), mmioStringToFOURCCA(), NPAddConnection3(), Open(), parseArguments(), PathMatchSingleMaskA(), PeLdrpCompareDllName(), PrintDriveLetter(), ProcessCmdLine(), Protect(), put_resource_id(), read_rcfile(), regdump(), RepairIntroPage(), Save(), SdbMakeIndexKeyFromString(), ServeOneClient(), ShimLib_StrAEqualsWNC(), StrCmpPath(), SymMatchFileName(), test_C_locale(), test_GetDrive(), test_GetVolumeInformationA(), test_PathNameA(), test_query_dos_deviceA(), test_RtlIsNameLegalDOS8Dot3(), to_upper(), toupper_str(), UpgradeRepairPage(), VfdBroadcastLink(), VfdGetLocalLink(), VfdSetGlobalLink(), VfdSetLocalLink(), WelcomePage(), wtstrcasecmp(), XCOPY_DoCopy(), XCOPY_ParseCommandLine(), XCOPY_ProcessDestParm(), xkeymap_read(), xmlAddEncodingAlias(), xmlFindCharEncodingHandler(), xmlGetEncodingAlias(), xmlNewCharEncodingHandler(), and xmlParseCharEncoding().