@@ -2497,14 +2497,15 @@ S_new_collate(pTHX_ const char *newcoll)
2497
2497
wchar_t *
2498
2498
S_Win_byte_string_to_wstring (const UINT code_page , const char * byte_string )
2499
2499
{
2500
- wchar_t * wstring ;
2500
+ /* Caller must arrange to free the returned string */
2501
2501
2502
2502
int req_size = MultiByteToWideChar (code_page , 0 , byte_string , -1 , NULL , 0 );
2503
2503
if (! req_size ) {
2504
2504
errno = EINVAL ;
2505
2505
return NULL ;
2506
2506
}
2507
2507
2508
+ wchar_t * wstring ;
2508
2509
Newx (wstring , req_size , wchar_t );
2509
2510
2510
2511
if (! MultiByteToWideChar (code_page , 0 , byte_string , -1 , wstring , req_size ))
@@ -2522,6 +2523,7 @@ S_Win_byte_string_to_wstring(const UINT code_page, const char * byte_string)
2522
2523
char *
2523
2524
S_Win_wstring_to_byte_string (const UINT code_page , const wchar_t * wstring )
2524
2525
{
2526
+ /* Caller must arrange to free the returned string */
2525
2527
2526
2528
int req_size =
2527
2529
WideCharToMultiByte (code_page , 0 , wstring , -1 , NULL , 0 , NULL , NULL );
@@ -2547,6 +2549,10 @@ S_wrap_wsetlocale(pTHX_ const int category, const char *locale)
2547
2549
{
2548
2550
PERL_ARGS_ASSERT_WRAP_WSETLOCALE ;
2549
2551
2552
+ /* Calls _wsetlocale(), converting the parameters/return to/from
2553
+ * Perl-expected forms as if plain setlocale() were being called instead.
2554
+ */
2555
+
2550
2556
const wchar_t * wlocale = NULL ;
2551
2557
2552
2558
if (locale ) {
@@ -2555,16 +2561,13 @@ S_wrap_wsetlocale(pTHX_ const int category, const char *locale)
2555
2561
return NULL ;
2556
2562
}
2557
2563
}
2558
- else {
2559
- wlocale = NULL ;
2560
- }
2561
2564
2562
2565
const wchar_t * wresult = _wsetlocale (category , wlocale );
2563
2566
Safefree (wlocale );
2564
2567
2565
2568
if (! wresult ) {
2566
- return NULL ;
2567
- }
2569
+ return NULL ;
2570
+ }
2568
2571
2569
2572
const char * result = Win_wstring_to_utf8_string (wresult );
2570
2573
SAVEFREEPV (result ); /* is there something better we can do here? */
0 commit comments