ReactOS 0.4.16-dev-937-g7afcd2a
wcslwr.cpp File Reference
#include <corecrt_internal.h>
#include <ctype.h>
#include <corecrt_internal_securecrt.h>
#include <locale.h>
#include <string.h>
Include dependency graph for wcslwr.cpp:

Go to the source code of this file.

Functions

wchar_t *__cdecl _wcslwr_l (wchar_t *wsrc, _locale_t plocinfo)
 
wchar_t *__cdecl _wcslwr (wchar_t *wsrc)
 
static errno_t __cdecl _wcslwr_s_l_stat (_Inout_updates_z_(sizeInWords) wchar_t *wsrc, size_t sizeInWords, _locale_t plocinfo)
 
errno_t __cdecl _wcslwr_s_l (wchar_t *wsrc, size_t sizeInWords, _locale_t plocinfo)
 
errno_t __cdecl _wcslwr_s (wchar_t *wsrc, size_t sizeInWords)
 

Function Documentation

◆ _wcslwr()

wchar_t *__cdecl _wcslwr ( wchar_t wsrc)

Definition at line 49 of file wcslwr.cpp.

52{
53 if (!__acrt_locale_changed())
54 {
55 wchar_t * p;
56
57 /* validation section */
58 _VALIDATE_RETURN(wsrc != nullptr, EINVAL, nullptr);
59
60 for (p=wsrc; *p; ++p)
61 {
62 if (L'A' <= *p && *p <= L'Z')
63 *p += (wchar_t)L'a' - (wchar_t)L'A';
64 }
65 } else {
66 _wcslwr_s_l(wsrc, (size_t)(-1), nullptr);
67 return wsrc;
68 }
69
70 return(wsrc);
71}
#define EINVAL
Definition: acclib.h:90
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
_wcslwr_s_l
GLfloat GLfloat p
Definition: glext.h:8902
#define L(x)
Definition: ntvdm.h:50
#define wchar_t
Definition: wchar.h:102

◆ _wcslwr_l()

wchar_t *__cdecl _wcslwr_l ( wchar_t wsrc,
_locale_t  plocinfo 
)

Definition at line 40 of file wcslwr.cpp.

44{
45 _wcslwr_s_l(wsrc, (size_t)(-1), plocinfo);
46 return wsrc;
47}
_locale_t plocinfo
Definition: ismbbyte.cpp:75

◆ _wcslwr_s()

errno_t __cdecl _wcslwr_s ( wchar_t wsrc,
size_t  sizeInWords 
)

Definition at line 186 of file wcslwr.cpp.

190{
191 return _wcslwr_s_l(wsrc, sizeInWords, nullptr);
192}

◆ _wcslwr_s_l()

errno_t __cdecl _wcslwr_s_l ( wchar_t wsrc,
size_t  sizeInWords,
_locale_t  plocinfo 
)

Definition at line 174 of file wcslwr.cpp.

179{
180 _LocaleUpdate _loc_update(plocinfo);
181
182 return _wcslwr_s_l_stat(wsrc, sizeInWords, _loc_update.GetLocaleT());
183}
static errno_t __cdecl _wcslwr_s_l_stat(_Inout_updates_z_(sizeInWords) wchar_t *wsrc, size_t sizeInWords, _locale_t plocinfo)
Definition: wcslwr.cpp:93

◆ _wcslwr_s_l_stat()

static errno_t __cdecl _wcslwr_s_l_stat ( _Inout_updates_z_(sizeInWords) wchar_t wsrc,
size_t  sizeInWords,
_locale_t  plocinfo 
)
static

Definition at line 93 of file wcslwr.cpp.

98{
99
100 wchar_t *p; /* traverses string for C locale conversion */
101 int dstsize; /* size in wide chars of wdst string buffer (include null) */
102 size_t stringlen;
103
104 /* validation section */
105 _VALIDATE_RETURN_ERRCODE(wsrc != nullptr, EINVAL);
106 stringlen = wcsnlen(wsrc, sizeInWords);
107 if (stringlen >= sizeInWords)
108 {
109 _RESET_STRING(wsrc, sizeInWords);
110 _RETURN_DEST_NOT_NULL_TERMINATED(wsrc, sizeInWords);
111 }
112 _FILL_STRING(wsrc, sizeInWords, stringlen + 1);
113
114 if ( plocinfo->locinfo->locale_name[LC_CTYPE] == nullptr)
115 {
116 for ( p = wsrc ; *p ; p++ )
117 {
118 if ( (*p >= (wchar_t)L'A') && (*p <= (wchar_t)L'Z') )
119 {
120 *p -= static_cast<wchar_t>(L'A' - L'a');
121 }
122 }
123
124 return 0;
125 } /* C locale */
126
127 /* Inquire size of wdst string */
128 if ( (dstsize = __acrt_LCMapStringW(
129 plocinfo->locinfo->locale_name[LC_CTYPE],
131 wsrc,
132 -1,
133 nullptr,
134 0
135 )) == 0 )
136 {
137 errno = EILSEQ;
138 return errno;
139 }
140
141 if (sizeInWords < (size_t)dstsize)
142 {
143 _RESET_STRING(wsrc, sizeInWords);
144 _RETURN_BUFFER_TOO_SMALL(wsrc, sizeInWords);
145 }
146
147 /* Allocate space for wdst */
148 __crt_scoped_stack_ptr<wchar_t> const wdst(_malloca_crt_t(wchar_t, dstsize));
149 if (!wdst)
150 {
151 errno = ENOMEM;
152 return errno;
153 }
154
155 /* Map wrc string to wide-character wdst string in alternate case */
157 plocinfo->locinfo->locale_name[LC_CTYPE],
159 wsrc,
160 -1,
161 wdst.get(),
162 dstsize
163 ) != 0)
164 {
165 /* Copy wdst string to user string */
166 return wcscpy_s(wsrc, sizeInWords, wdst.get());
167 }
168 else
169 {
170 return errno = EILSEQ;
171 }
172}
int __cdecl __acrt_LCMapStringW(LPCWSTR const locale_name, DWORD const map_flags, LPCWSTR const source, int source_count, LPWSTR const destination, int const destination_count)
#define ENOMEM
Definition: acclib.h:84
#define _RETURN_DEST_NOT_NULL_TERMINATED(_String, _Size)
#define _FILL_STRING
#define _RETURN_BUFFER_TOO_SMALL(_String, _Size)
#define _RESET_STRING(_String, _Size)
GLint const GLchar GLint stringlen
Definition: glext.h:7232
#define LC_CTYPE
Definition: locale.h:19
#define _VALIDATE_RETURN_ERRCODE(expr, errorcode)
#define wcscpy_s(d, l, s)
Definition: utility.h:201
#define errno
Definition: errno.h:18
#define EILSEQ
Definition: errno.h:109
size_t __cdecl wcsnlen(wchar_t const *const string, size_t const maximum_count)
Definition: strnlen.cpp:210
pthreadlocinfo locinfo
Definition: corecrt.h:23
#define LCMAP_LOWERCASE
Definition: winnls.h:186

Referenced by _wcslwr_s_l().