2001-01-11 00:59:25 +01:00
|
|
|
/*
|
|
|
|
* msvcrt.dll locale functions
|
|
|
|
*
|
|
|
|
* Copyright 2000 Jon Griffiths
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2002-04-26 21:05:15 +02:00
|
|
|
|
2009-10-22 22:26:45 +02:00
|
|
|
#include <limits.h>
|
2003-08-07 00:08:04 +02:00
|
|
|
#include <locale.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2003-08-07 00:08:04 +02:00
|
|
|
#include <stdio.h>
|
2020-11-19 13:28:52 +01:00
|
|
|
#include <stdlib.h>
|
2020-11-20 12:44:42 +01:00
|
|
|
#include <mbctype.h>
|
|
|
|
#include <wctype.h>
|
2003-08-07 00:08:04 +02:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2001-10-10 04:51:24 +02:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
2006-07-10 11:54:10 +02:00
|
|
|
#include "winnls.h"
|
2001-09-19 22:29:33 +02:00
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
#include "msvcrt.h"
|
2002-02-21 21:22:00 +01:00
|
|
|
#include "mtdll.h"
|
2001-01-11 00:59:25 +01:00
|
|
|
|
2002-01-22 01:57:16 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
|
2001-01-11 00:59:25 +01:00
|
|
|
|
|
|
|
#define MAX_ELEM_LEN 64 /* Max length of country/language/CP string */
|
|
|
|
#define MAX_LOCALE_LENGTH 256
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t MSVCRT_locale = NULL;
|
2011-10-12 11:56:04 +02:00
|
|
|
unsigned short *MSVCRT__pctype = NULL;
|
2011-12-21 15:59:09 +01:00
|
|
|
unsigned int MSVCRT___lc_codepage = 0;
|
2010-04-16 12:01:35 +02:00
|
|
|
int MSVCRT___lc_collate_cp = 0;
|
2020-11-30 14:37:48 +01:00
|
|
|
LCID MSVCRT___lc_handle[LC_MAX - LC_MIN + 1] = { 0 };
|
2011-10-12 11:55:35 +02:00
|
|
|
int MSVCRT___mb_cur_max = 1;
|
2019-01-23 11:59:05 +01:00
|
|
|
BOOL initial_locale = TRUE;
|
2001-01-11 00:59:25 +01:00
|
|
|
|
|
|
|
#define MSVCRT_LEADBYTE 0x8000
|
2010-04-19 10:58:19 +02:00
|
|
|
#define MSVCRT_C1_DEFINED 0x200
|
2001-01-11 00:59:25 +01:00
|
|
|
|
2020-11-26 19:19:09 +01:00
|
|
|
__lc_time_data cloc_time_data =
|
2019-12-04 16:22:14 +01:00
|
|
|
{
|
|
|
|
{{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
|
|
|
|
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",
|
|
|
|
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
|
|
|
"January", "February", "March", "April", "May", "June", "July",
|
|
|
|
"August", "September", "October", "November", "December",
|
|
|
|
"AM", "PM", "MM/dd/yy", "dddd, MMMM dd, yyyy", "HH:mm:ss"}},
|
|
|
|
#if _MSVCR_VER < 110
|
|
|
|
MAKELCID(LANG_ENGLISH, SORT_DEFAULT),
|
|
|
|
#endif
|
2020-11-18 17:26:15 +01:00
|
|
|
1, 0,
|
2021-02-02 18:55:12 +01:00
|
|
|
#if _MSVCR_VER == 0 || _MSVCR_VER >= 100
|
2020-11-27 14:16:53 +01:00
|
|
|
{{L"Sun", L"Mon", L"Tue", L"Wed", L"Thu", L"Fri", L"Sat",
|
|
|
|
L"Sunday", L"Monday", L"Tuesday", L"Wednesday", L"Thursday", L"Friday", L"Saturday",
|
|
|
|
L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec",
|
|
|
|
L"January", L"February", L"March", L"April", L"May", L"June", L"July",
|
|
|
|
L"August", L"September", L"October", L"November", L"December",
|
|
|
|
L"AM", L"PM", L"MM/dd/yy", L"dddd, MMMM dd, yyyy", L"HH:mm:ss"}},
|
2021-02-02 18:55:12 +01:00
|
|
|
#endif
|
2019-12-04 16:22:14 +01:00
|
|
|
#if _MSVCR_VER >= 110
|
2020-11-27 14:16:53 +01:00
|
|
|
L"en-US",
|
2019-12-04 16:22:14 +01:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2020-11-18 17:26:05 +01:00
|
|
|
static const unsigned char cloc_clmap[256] =
|
|
|
|
{
|
|
|
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
|
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
|
|
|
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
|
|
|
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
|
|
|
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
|
|
|
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
|
|
|
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
|
|
|
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
|
|
|
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
|
|
|
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
|
|
|
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
|
|
|
0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
|
|
|
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
|
|
|
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
|
|
|
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
|
|
|
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
|
|
|
|
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
|
|
|
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
|
|
|
|
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
|
|
|
|
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
|
|
|
|
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
|
|
|
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
|
|
|
|
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
|
|
|
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
|
|
|
|
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
|
|
|
|
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
|
|
|
|
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
|
|
|
|
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
|
|
|
|
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
|
|
|
|
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
|
|
|
|
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
|
|
|
|
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
|
|
|
|
};
|
|
|
|
|
|
|
|
static const unsigned char cloc_cumap[256] =
|
|
|
|
{
|
|
|
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
|
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
|
|
|
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
|
|
|
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
|
|
|
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
|
|
|
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
|
|
|
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
|
|
|
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
|
|
|
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
|
|
|
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
|
|
|
|
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
|
|
|
0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
|
|
|
0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
|
|
|
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
|
|
|
|
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
|
|
|
0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
|
|
|
|
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
|
|
|
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
|
|
|
|
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
|
|
|
|
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
|
|
|
|
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
|
|
|
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
|
|
|
|
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
|
|
|
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
|
|
|
|
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
|
|
|
|
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
|
|
|
|
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
|
|
|
|
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
|
|
|
|
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
|
|
|
|
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
|
|
|
|
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
|
|
|
|
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
|
|
|
|
};
|
|
|
|
|
2020-11-18 17:26:10 +01:00
|
|
|
static char empty[] = "";
|
|
|
|
static char cloc_dec_point[] = ".";
|
|
|
|
#if _MSVCR_VER >= 100
|
2020-11-27 14:16:53 +01:00
|
|
|
static wchar_t emptyW[] = L"";
|
|
|
|
static wchar_t cloc_dec_pointW[] = L".";
|
2020-11-18 17:26:10 +01:00
|
|
|
#endif
|
2020-11-26 19:19:05 +01:00
|
|
|
static struct lconv cloc_lconv =
|
2020-11-18 17:26:10 +01:00
|
|
|
{
|
|
|
|
cloc_dec_point, empty, empty, empty, empty, empty, empty, empty, empty, empty,
|
|
|
|
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
|
|
|
|
#if _MSVCR_VER >= 100
|
|
|
|
cloc_dec_pointW, emptyW, emptyW, emptyW, emptyW, emptyW, emptyW, emptyW
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2010-05-09 23:39:17 +02:00
|
|
|
/* Friendly country strings & language names abbreviations. */
|
2006-12-14 15:47:24 +01:00
|
|
|
static const char * const _country_synonyms[] =
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2010-05-09 23:39:17 +02:00
|
|
|
"american", "enu",
|
|
|
|
"american english", "enu",
|
|
|
|
"american-english", "enu",
|
|
|
|
"english-american", "enu",
|
|
|
|
"english-us", "enu",
|
|
|
|
"english-usa", "enu",
|
|
|
|
"us", "enu",
|
|
|
|
"usa", "enu",
|
|
|
|
"australian", "ena",
|
|
|
|
"english-aus", "ena",
|
|
|
|
"belgian", "nlb",
|
|
|
|
"french-belgian", "frb",
|
|
|
|
"canadian", "enc",
|
|
|
|
"english-can", "enc",
|
|
|
|
"french-canadian", "frc",
|
|
|
|
"chinese", "chs",
|
|
|
|
"chinese-simplified", "chs",
|
|
|
|
"chinese-traditional", "cht",
|
|
|
|
"dutch-belgian", "nlb",
|
|
|
|
"english-nz", "enz",
|
|
|
|
"uk", "eng",
|
|
|
|
"english-uk", "eng",
|
|
|
|
"french-swiss", "frs",
|
|
|
|
"swiss", "des",
|
|
|
|
"german-swiss", "des",
|
|
|
|
"italian-swiss", "its",
|
|
|
|
"german-austrian", "dea",
|
2012-06-13 19:47:54 +02:00
|
|
|
"portuguese", "ptb",
|
2010-05-09 23:39:17 +02:00
|
|
|
"portuguese-brazil", "ptb",
|
|
|
|
"spanish-mexican", "esm",
|
|
|
|
"norwegian-bokmal", "nor",
|
|
|
|
"norwegian-nynorsk", "non",
|
|
|
|
"spanish-modern", "esn"
|
2001-01-11 00:59:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* INTERNAL: Map a synonym to an ISO code */
|
|
|
|
static void remap_synonym(char *name)
|
|
|
|
{
|
2009-05-27 11:39:05 +02:00
|
|
|
unsigned int i;
|
2018-07-26 00:05:52 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(_country_synonyms); i += 2)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-02 00:54:09 +01:00
|
|
|
if (!_stricmp(_country_synonyms[i],name))
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
TRACE(":Mapping synonym %s to %s\n",name,_country_synonyms[i+1]);
|
2011-10-17 00:42:28 +02:00
|
|
|
strcpy(name, _country_synonyms[i+1]);
|
2001-01-11 00:59:25 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Note: Flags are weighted in order of matching importance */
|
2020-09-18 15:52:54 +02:00
|
|
|
#define FOUND_SNAME 0x4
|
|
|
|
#define FOUND_LANGUAGE 0x2
|
|
|
|
#define FOUND_COUNTRY 0x1
|
2001-01-11 00:59:25 +01:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char search_language[MAX_ELEM_LEN];
|
|
|
|
char search_country[MAX_ELEM_LEN];
|
2020-01-24 18:28:53 +01:00
|
|
|
DWORD found_codepage;
|
2001-01-11 00:59:25 +01:00
|
|
|
unsigned int match_flags;
|
|
|
|
LANGID found_lang_id;
|
2020-09-18 15:52:54 +02:00
|
|
|
BOOL allow_sname;
|
2001-01-11 00:59:25 +01:00
|
|
|
} locale_search_t;
|
|
|
|
|
|
|
|
#define CONTINUE_LOOKING TRUE
|
|
|
|
#define STOP_LOOKING FALSE
|
|
|
|
|
|
|
|
/* INTERNAL: Get and compare locale info with a given string */
|
2010-05-09 23:39:17 +02:00
|
|
|
static int compare_info(LCID lcid, DWORD flags, char* buff, const char* cmp, BOOL exact)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2010-05-09 23:39:17 +02:00
|
|
|
int len;
|
|
|
|
|
2012-12-18 11:39:00 +01:00
|
|
|
if(!cmp[0])
|
|
|
|
return 0;
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
buff[0] = 0;
|
2010-05-09 23:39:17 +02:00
|
|
|
GetLocaleInfoA(lcid, flags|LOCALE_NOUSEROVERRIDE, buff, MAX_ELEM_LEN);
|
2012-12-18 11:39:00 +01:00
|
|
|
if (!buff[0])
|
2001-01-11 00:59:25 +01:00
|
|
|
return 0;
|
2010-05-09 23:39:17 +02:00
|
|
|
|
|
|
|
/* Partial matches are only allowed on language/country names */
|
|
|
|
len = strlen(cmp);
|
|
|
|
if(exact || len<=3)
|
2020-12-02 00:54:09 +01:00
|
|
|
return !_stricmp(cmp, buff);
|
2010-05-09 23:39:17 +02:00
|
|
|
else
|
2020-12-02 00:54:09 +01:00
|
|
|
return !_strnicmp(cmp, buff, len);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL CALLBACK
|
2005-09-12 17:14:06 +02:00
|
|
|
find_best_locale_proc(HMODULE hModule, LPCSTR type, LPCSTR name, WORD LangID, LONG_PTR lParam)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
locale_search_t *res = (locale_search_t *)lParam;
|
|
|
|
const LCID lcid = MAKELCID(LangID, SORT_DEFAULT);
|
|
|
|
char buff[MAX_ELEM_LEN];
|
|
|
|
unsigned int flags = 0;
|
|
|
|
|
|
|
|
if(PRIMARYLANGID(LangID) == LANG_NEUTRAL)
|
|
|
|
return CONTINUE_LOOKING;
|
|
|
|
|
2018-05-09 17:36:17 +02:00
|
|
|
#if _MSVCR_VER >= 110
|
2020-09-18 15:52:54 +02:00
|
|
|
if (res->allow_sname && compare_info(lcid,LOCALE_SNAME,buff,res->search_language, TRUE))
|
2018-05-09 17:36:17 +02:00
|
|
|
{
|
|
|
|
TRACE(":Found locale: %s->%s\n", res->search_language, buff);
|
|
|
|
res->match_flags = FOUND_SNAME;
|
|
|
|
res->found_lang_id = LangID;
|
|
|
|
return STOP_LOOKING;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/* Check Language */
|
2010-05-09 23:39:17 +02:00
|
|
|
if (compare_info(lcid,LOCALE_SISO639LANGNAME,buff,res->search_language, TRUE) ||
|
|
|
|
compare_info(lcid,LOCALE_SABBREVLANGNAME,buff,res->search_language, TRUE) ||
|
|
|
|
compare_info(lcid,LOCALE_SENGLANGUAGE,buff,res->search_language, FALSE))
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
TRACE(":Found language: %s->%s\n", res->search_language, buff);
|
|
|
|
flags |= FOUND_LANGUAGE;
|
|
|
|
}
|
|
|
|
else if (res->match_flags & FOUND_LANGUAGE)
|
|
|
|
{
|
|
|
|
return CONTINUE_LOOKING;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check Country */
|
2010-05-09 23:39:17 +02:00
|
|
|
if (compare_info(lcid,LOCALE_SISO3166CTRYNAME,buff,res->search_country, TRUE) ||
|
|
|
|
compare_info(lcid,LOCALE_SABBREVCTRYNAME,buff,res->search_country, TRUE) ||
|
|
|
|
compare_info(lcid,LOCALE_SENGCOUNTRY,buff,res->search_country, FALSE))
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
TRACE("Found country:%s->%s\n", res->search_country, buff);
|
|
|
|
flags |= FOUND_COUNTRY;
|
|
|
|
}
|
2012-12-18 11:39:00 +01:00
|
|
|
else if (!flags && (res->match_flags & FOUND_COUNTRY))
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
return CONTINUE_LOOKING;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags > res->match_flags)
|
|
|
|
{
|
|
|
|
/* Found a better match than previously */
|
|
|
|
res->match_flags = flags;
|
|
|
|
res->found_lang_id = LangID;
|
|
|
|
}
|
2020-09-18 15:52:54 +02:00
|
|
|
if ((flags & (FOUND_LANGUAGE | FOUND_COUNTRY)) ==
|
|
|
|
(FOUND_LANGUAGE | FOUND_COUNTRY))
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
TRACE(":found exact locale match\n");
|
|
|
|
return STOP_LOOKING;
|
|
|
|
}
|
|
|
|
return CONTINUE_LOOKING;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Internal: Find the LCID for a locale specification */
|
2020-11-26 19:19:24 +01:00
|
|
|
LCID locale_to_LCID(const char *locale, unsigned short *codepage, BOOL *sname)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2015-06-24 15:13:07 +02:00
|
|
|
thread_data_t *data = msvcrt_get_thread_data();
|
2011-08-22 21:31:47 +02:00
|
|
|
const char *cp, *region;
|
2020-09-18 15:52:54 +02:00
|
|
|
BOOL is_sname = FALSE;
|
|
|
|
DWORD locale_cp;
|
|
|
|
LCID lcid;
|
2010-04-15 14:26:01 +02:00
|
|
|
|
2015-06-24 15:13:07 +02:00
|
|
|
if (!strcmp(locale, data->cached_locale)) {
|
|
|
|
if (codepage)
|
|
|
|
*codepage = data->cached_cp;
|
2018-05-09 17:36:17 +02:00
|
|
|
if (sname)
|
|
|
|
*sname = data->cached_sname;
|
2015-06-24 15:13:07 +02:00
|
|
|
return data->cached_lcid;
|
|
|
|
}
|
|
|
|
|
2010-04-15 14:26:01 +02:00
|
|
|
cp = strchr(locale, '.');
|
|
|
|
region = strchr(locale, '_');
|
|
|
|
|
2020-09-18 15:52:54 +02:00
|
|
|
if(!locale[0] || (cp == locale && !region)) {
|
|
|
|
lcid = GetUserDefaultLCID();
|
|
|
|
} else {
|
|
|
|
locale_search_t search;
|
|
|
|
|
|
|
|
memset(&search, 0, sizeof(locale_search_t));
|
|
|
|
lstrcpynA(search.search_language, locale, MAX_ELEM_LEN);
|
|
|
|
if(region) {
|
|
|
|
lstrcpynA(search.search_country, region+1, MAX_ELEM_LEN);
|
|
|
|
if(region-locale < MAX_ELEM_LEN)
|
|
|
|
search.search_language[region-locale] = '\0';
|
|
|
|
} else
|
|
|
|
search.search_country[0] = '\0';
|
|
|
|
|
|
|
|
if(cp) {
|
|
|
|
if(region && cp-region-1<MAX_ELEM_LEN)
|
|
|
|
search.search_country[cp-region-1] = '\0';
|
|
|
|
if(cp-locale < MAX_ELEM_LEN)
|
|
|
|
search.search_language[cp-locale] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!cp && !region)
|
|
|
|
{
|
|
|
|
remap_synonym(search.search_language);
|
|
|
|
search.allow_sname = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), (LPSTR)RT_STRING,
|
|
|
|
(LPCSTR)LOCALE_ILANGUAGE,find_best_locale_proc,
|
|
|
|
(LONG_PTR)&search);
|
2010-04-15 14:26:01 +02:00
|
|
|
|
2020-09-18 15:52:54 +02:00
|
|
|
if (!search.match_flags)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* If we were given something that didn't match, fail */
|
|
|
|
if (search.search_language[0] && !(search.match_flags & (FOUND_SNAME | FOUND_LANGUAGE)))
|
|
|
|
return -1;
|
|
|
|
if (search.search_country[0] && !(search.match_flags & FOUND_COUNTRY))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
lcid = MAKELCID(search.found_lang_id, SORT_DEFAULT);
|
|
|
|
is_sname = (search.match_flags & FOUND_SNAME) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Obtain code page */
|
2020-12-02 00:54:09 +01:00
|
|
|
if (!cp || !cp[1] || !_strnicmp(cp, ".ACP", 4)) {
|
2020-09-18 15:52:54 +02:00
|
|
|
GetLocaleInfoW(lcid, LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
|
|
|
|
(WCHAR *)&locale_cp, sizeof(DWORD)/sizeof(WCHAR));
|
|
|
|
if (!locale_cp)
|
|
|
|
locale_cp = GetACP();
|
2020-12-02 00:54:09 +01:00
|
|
|
} else if (!_strnicmp(cp, ".OCP", 4)) {
|
2020-09-18 15:52:54 +02:00
|
|
|
GetLocaleInfoW(lcid, LOCALE_IDEFAULTCODEPAGE | LOCALE_RETURN_NUMBER,
|
|
|
|
(WCHAR *)&locale_cp, sizeof(DWORD)/sizeof(WCHAR));
|
2020-11-11 18:49:08 +01:00
|
|
|
#if _MSVCR_VER >= 140
|
2020-12-02 00:54:09 +01:00
|
|
|
} else if (!_strnicmp(cp, ".UTF-8", 6)
|
|
|
|
|| !_strnicmp(cp, ".UTF8", 5)) {
|
2020-11-11 18:49:08 +01:00
|
|
|
locale_cp = CP_UTF8;
|
|
|
|
#endif
|
2020-09-18 15:52:54 +02:00
|
|
|
} else {
|
2020-12-02 00:54:09 +01:00
|
|
|
locale_cp = atoi(cp + 1);
|
2020-09-18 15:52:54 +02:00
|
|
|
}
|
|
|
|
if (!IsValidCodePage(locale_cp))
|
2018-05-09 17:36:17 +02:00
|
|
|
return -1;
|
2020-09-18 15:52:54 +02:00
|
|
|
|
|
|
|
if (!locale_cp)
|
2010-04-19 10:58:10 +02:00
|
|
|
return -1;
|
2010-04-15 14:26:01 +02:00
|
|
|
|
2012-12-18 11:38:33 +01:00
|
|
|
if (codepage)
|
2020-09-18 15:52:54 +02:00
|
|
|
*codepage = locale_cp;
|
2018-05-09 17:36:17 +02:00
|
|
|
if (sname)
|
2020-09-18 15:52:54 +02:00
|
|
|
*sname = is_sname;
|
2010-04-15 14:26:01 +02:00
|
|
|
|
2015-06-24 15:13:07 +02:00
|
|
|
if (strlen(locale) < sizeof(data->cached_locale)) {
|
|
|
|
strcpy(data->cached_locale, locale);
|
|
|
|
data->cached_lcid = lcid;
|
2020-09-18 15:52:54 +02:00
|
|
|
data->cached_cp = locale_cp;
|
|
|
|
data->cached_sname = is_sname;
|
2015-06-24 15:13:07 +02:00
|
|
|
}
|
|
|
|
|
2010-04-15 14:26:01 +02:00
|
|
|
return lcid;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2020-11-26 19:19:09 +01:00
|
|
|
static void copy_threadlocinfo_category(pthreadlocinfo locinfo,
|
|
|
|
const threadlocinfo *old_locinfo, int category)
|
2020-11-18 17:25:50 +01:00
|
|
|
{
|
|
|
|
locinfo->lc_handle[category] = old_locinfo->lc_handle[category];
|
|
|
|
locinfo->lc_id[category] = old_locinfo->lc_id[category];
|
|
|
|
if(!locinfo->lc_category[category].locale) {
|
|
|
|
locinfo->lc_category[category].locale = old_locinfo->lc_category[category].locale;
|
|
|
|
locinfo->lc_category[category].refcount = old_locinfo->lc_category[category].refcount;
|
2022-02-03 11:50:30 +01:00
|
|
|
InterlockedIncrement((LONG *)locinfo->lc_category[category].refcount);
|
2020-11-18 17:25:50 +01:00
|
|
|
}
|
|
|
|
#if _MSVCR_VER >= 110
|
|
|
|
locinfo->lc_name[category] = old_locinfo->lc_name[category];
|
|
|
|
locinfo->lc_category[category].wrefcount = old_locinfo->lc_category[category].wrefcount;
|
|
|
|
if(locinfo->lc_category[category].wrefcount)
|
2022-02-03 11:50:30 +01:00
|
|
|
InterlockedIncrement((LONG *)locinfo->lc_category[category].wrefcount);
|
2020-11-18 17:25:50 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-05-09 17:36:17 +02:00
|
|
|
static BOOL init_category_name(const char *name, int len,
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo locinfo, int category)
|
2018-05-09 17:36:17 +02:00
|
|
|
{
|
2020-12-01 13:51:32 +01:00
|
|
|
locinfo->lc_category[category].locale = malloc(len+1);
|
|
|
|
locinfo->lc_category[category].refcount = malloc(sizeof(int));
|
2018-05-09 17:36:17 +02:00
|
|
|
if(!locinfo->lc_category[category].locale
|
|
|
|
|| !locinfo->lc_category[category].refcount) {
|
2020-12-01 13:51:32 +01:00
|
|
|
free(locinfo->lc_category[category].locale);
|
|
|
|
free(locinfo->lc_category[category].refcount);
|
2018-05-09 17:36:17 +02:00
|
|
|
locinfo->lc_category[category].locale = NULL;
|
|
|
|
locinfo->lc_category[category].refcount = NULL;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(locinfo->lc_category[category].locale, name, len);
|
|
|
|
locinfo->lc_category[category].locale[len] = 0;
|
|
|
|
*locinfo->lc_category[category].refcount = 1;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-11-18 17:25:44 +01:00
|
|
|
#if _MSVCR_VER >= 110
|
2020-11-26 19:19:09 +01:00
|
|
|
static inline BOOL set_lc_locale_name(pthreadlocinfo locinfo, int cat)
|
2020-11-18 17:25:44 +01:00
|
|
|
{
|
|
|
|
LCID lcid = locinfo->lc_handle[cat];
|
|
|
|
WCHAR buf[100];
|
|
|
|
int len;
|
|
|
|
|
2020-12-01 13:51:32 +01:00
|
|
|
locinfo->lc_category[cat].wrefcount = malloc(sizeof(int));
|
2020-11-18 17:25:47 +01:00
|
|
|
if(!locinfo->lc_category[cat].wrefcount)
|
|
|
|
return FALSE;
|
|
|
|
*locinfo->lc_category[cat].wrefcount = 1;
|
|
|
|
|
2020-11-18 17:25:44 +01:00
|
|
|
len = GetLocaleInfoW(lcid, LOCALE_SISO639LANGNAME
|
|
|
|
|LOCALE_NOUSEROVERRIDE, buf, 100);
|
|
|
|
if(!len) return FALSE;
|
|
|
|
|
|
|
|
if(LocaleNameToLCID(buf, 0) != lcid)
|
|
|
|
len = LCIDToLocaleName(lcid, buf, 100, 0);
|
|
|
|
|
2020-12-01 13:51:32 +01:00
|
|
|
if(!len || !(locinfo->lc_name[cat] = malloc(len*sizeof(wchar_t))))
|
2020-11-18 17:25:44 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2020-11-27 14:16:49 +01:00
|
|
|
memcpy(locinfo->lc_name[cat], buf, len*sizeof(wchar_t));
|
2020-11-18 17:25:44 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
#else
|
2020-11-26 19:19:09 +01:00
|
|
|
static inline BOOL set_lc_locale_name(pthreadlocinfo locinfo, int cat)
|
2020-11-18 17:25:44 +01:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-04-08 10:24:25 +02:00
|
|
|
/* INTERNAL: Set lc_handle, lc_id and lc_category in threadlocinfo struct */
|
2012-12-18 11:38:33 +01:00
|
|
|
static BOOL update_threadlocinfo_category(LCID lcid, unsigned short cp,
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo locinfo, int category)
|
2010-04-08 10:24:25 +02:00
|
|
|
{
|
|
|
|
char buf[256], *p;
|
|
|
|
|
2010-05-09 23:38:11 +02:00
|
|
|
if(GetLocaleInfoA(lcid, LOCALE_ILANGUAGE|LOCALE_NOUSEROVERRIDE, buf, 256)) {
|
2010-04-08 10:24:25 +02:00
|
|
|
p = buf;
|
|
|
|
|
2015-09-24 16:15:40 +02:00
|
|
|
locinfo->lc_id[category].wLanguage = 0;
|
2010-04-08 10:24:25 +02:00
|
|
|
while(*p) {
|
2015-09-24 16:15:40 +02:00
|
|
|
locinfo->lc_id[category].wLanguage *= 16;
|
2010-04-08 10:24:25 +02:00
|
|
|
|
|
|
|
if(*p <= '9')
|
2015-09-24 16:15:40 +02:00
|
|
|
locinfo->lc_id[category].wLanguage += *p-'0';
|
2010-04-08 10:24:25 +02:00
|
|
|
else
|
2015-09-24 16:15:40 +02:00
|
|
|
locinfo->lc_id[category].wLanguage += *p-'a'+10;
|
2010-04-08 10:24:25 +02:00
|
|
|
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
2015-09-24 16:15:40 +02:00
|
|
|
locinfo->lc_id[category].wCountry =
|
|
|
|
locinfo->lc_id[category].wLanguage;
|
2010-04-08 10:24:25 +02:00
|
|
|
}
|
|
|
|
|
2015-09-24 16:15:40 +02:00
|
|
|
locinfo->lc_id[category].wCodePage = cp;
|
2010-04-08 10:24:25 +02:00
|
|
|
|
2015-09-24 16:15:40 +02:00
|
|
|
locinfo->lc_handle[category] = lcid;
|
2010-04-08 10:24:25 +02:00
|
|
|
|
2020-11-18 17:25:44 +01:00
|
|
|
set_lc_locale_name(locinfo, category);
|
|
|
|
|
2018-05-09 17:36:17 +02:00
|
|
|
if(!locinfo->lc_category[category].locale) {
|
|
|
|
int len = 0;
|
|
|
|
|
2022-03-28 12:26:34 +02:00
|
|
|
if (lcid == MAKELANGID( LANG_NORWEGIAN, SUBLANG_NORWEGIAN_NYNORSK ))
|
|
|
|
{
|
|
|
|
/* locale.nls contains "Norwegian Nynorsk" instead for LOCALE_SENGLANGUAGE */
|
|
|
|
strcpy( buf, "Norwegian-Nynorsk" );
|
|
|
|
len = strlen( buf ) + 1;
|
|
|
|
}
|
|
|
|
else len += GetLocaleInfoA(lcid, LOCALE_SENGLANGUAGE|LOCALE_NOUSEROVERRIDE, buf, 256);
|
2018-05-09 17:36:17 +02:00
|
|
|
buf[len-1] = '_';
|
|
|
|
len += GetLocaleInfoA(lcid, LOCALE_SENGCOUNTRY
|
|
|
|
|LOCALE_NOUSEROVERRIDE, &buf[len], 256-len);
|
|
|
|
buf[len-1] = '.';
|
2020-12-03 19:10:54 +01:00
|
|
|
sprintf(buf+len, "%d", cp);
|
2018-05-09 17:36:17 +02:00
|
|
|
len += strlen(buf+len);
|
|
|
|
|
|
|
|
return init_category_name(buf, len, locinfo, category);
|
2010-04-08 10:24:25 +02:00
|
|
|
}
|
|
|
|
|
2018-05-09 17:36:17 +02:00
|
|
|
return TRUE;
|
2010-04-08 10:24:25 +02:00
|
|
|
}
|
|
|
|
|
2020-11-25 20:24:34 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _lock_locales (UCRTBASE.@)
|
|
|
|
*/
|
|
|
|
void CDECL _lock_locales(void)
|
|
|
|
{
|
|
|
|
_lock(_SETLOCALE_LOCK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _unlock_locales (UCRTBASE.@)
|
|
|
|
*/
|
|
|
|
void CDECL _unlock_locales(void)
|
|
|
|
{
|
|
|
|
_unlock(_SETLOCALE_LOCK);
|
|
|
|
}
|
|
|
|
|
2021-09-03 11:50:32 +02:00
|
|
|
static void grab_locinfo(pthreadlocinfo locinfo)
|
2020-11-25 20:24:34 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2022-02-03 11:50:30 +01:00
|
|
|
InterlockedIncrement((LONG *)&locinfo->refcount);
|
2020-11-30 14:37:48 +01:00
|
|
|
for(i=LC_MIN+1; i<=LC_MAX; i++)
|
2020-11-25 20:24:34 +01:00
|
|
|
{
|
2022-02-03 11:50:30 +01:00
|
|
|
InterlockedIncrement((LONG *)locinfo->lc_category[i].refcount);
|
2020-11-25 20:24:34 +01:00
|
|
|
if(locinfo->lc_category[i].wrefcount)
|
2022-02-03 11:50:30 +01:00
|
|
|
InterlockedIncrement((LONG *)locinfo->lc_category[i].wrefcount);
|
2020-11-25 20:24:34 +01:00
|
|
|
}
|
|
|
|
if(locinfo->lconv_intl_refcount)
|
2022-02-03 11:50:30 +01:00
|
|
|
InterlockedIncrement((LONG *)locinfo->lconv_intl_refcount);
|
2020-11-25 20:24:34 +01:00
|
|
|
if(locinfo->lconv_num_refcount)
|
2022-02-03 11:50:30 +01:00
|
|
|
InterlockedIncrement((LONG *)locinfo->lconv_num_refcount);
|
2020-11-25 20:24:34 +01:00
|
|
|
if(locinfo->lconv_mon_refcount)
|
2022-02-03 11:50:30 +01:00
|
|
|
InterlockedIncrement((LONG *)locinfo->lconv_mon_refcount);
|
2020-11-25 20:24:34 +01:00
|
|
|
if(locinfo->ctype1_refcount)
|
2022-02-03 11:50:30 +01:00
|
|
|
InterlockedIncrement((LONG *)locinfo->ctype1_refcount);
|
2020-11-25 20:24:34 +01:00
|
|
|
InterlockedIncrement(&locinfo->lc_time_curr->refcount);
|
|
|
|
}
|
|
|
|
|
2021-09-03 11:50:32 +02:00
|
|
|
static void update_thread_locale(thread_data_t *data)
|
2020-11-25 20:24:34 +01:00
|
|
|
{
|
|
|
|
if((data->locale_flags & LOCALE_FREE) && ((data->locale_flags & LOCALE_THREAD) ||
|
|
|
|
(data->locinfo == MSVCRT_locale->locinfo && data->mbcinfo == MSVCRT_locale->mbcinfo)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(data->locale_flags & LOCALE_FREE)
|
|
|
|
{
|
|
|
|
free_locinfo(data->locinfo);
|
|
|
|
free_mbcinfo(data->mbcinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
_lock_locales();
|
|
|
|
data->locinfo = MSVCRT_locale->locinfo;
|
|
|
|
grab_locinfo(data->locinfo);
|
|
|
|
_unlock_locales();
|
|
|
|
|
|
|
|
_lock(_MB_CP_LOCK);
|
|
|
|
data->mbcinfo = MSVCRT_locale->mbcinfo;
|
|
|
|
InterlockedIncrement(&data->mbcinfo->refcount);
|
|
|
|
_unlock(_MB_CP_LOCK);
|
|
|
|
|
|
|
|
data->locale_flags |= LOCALE_FREE;
|
|
|
|
}
|
|
|
|
|
2020-11-18 17:26:24 +01:00
|
|
|
/* INTERNAL: returns threadlocinfo struct */
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo CDECL get_locinfo(void) {
|
2020-11-25 20:24:34 +01:00
|
|
|
thread_data_t *data = msvcrt_get_thread_data();
|
|
|
|
update_thread_locale(data);
|
|
|
|
return data->locinfo;
|
2010-04-15 14:25:34 +02:00
|
|
|
}
|
|
|
|
|
2020-11-25 20:24:30 +01:00
|
|
|
/* INTERNAL: returns pthreadmbcinfo struct */
|
2020-11-26 19:19:13 +01:00
|
|
|
pthreadmbcinfo CDECL get_mbcinfo(void) {
|
2011-05-24 17:22:32 +02:00
|
|
|
thread_data_t *data = msvcrt_get_thread_data();
|
2020-11-25 20:24:34 +01:00
|
|
|
update_thread_locale(data);
|
2020-11-25 20:24:30 +01:00
|
|
|
return data->mbcinfo;
|
2011-05-24 17:22:32 +02:00
|
|
|
}
|
|
|
|
|
2010-04-19 10:58:51 +02:00
|
|
|
/* INTERNAL: constructs string returned by setlocale */
|
2020-11-26 19:19:09 +01:00
|
|
|
static inline char* construct_lc_all(pthreadlocinfo locinfo) {
|
2010-04-19 10:58:51 +02:00
|
|
|
static char current_lc_all[MAX_LOCALE_LENGTH];
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
for(i=LC_MIN+1; i<LC_MAX; i++) {
|
2011-05-24 17:22:42 +02:00
|
|
|
if(strcmp(locinfo->lc_category[i].locale,
|
|
|
|
locinfo->lc_category[i+1].locale))
|
2010-04-19 10:58:51 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(i==LC_MAX)
|
|
|
|
return locinfo->lc_category[LC_COLLATE].locale;
|
2010-04-19 10:58:51 +02:00
|
|
|
|
2020-12-03 19:10:54 +01:00
|
|
|
sprintf(current_lc_all,
|
2010-04-19 10:58:51 +02:00
|
|
|
"LC_COLLATE=%s;LC_CTYPE=%s;LC_MONETARY=%s;LC_NUMERIC=%s;LC_TIME=%s",
|
2020-11-30 14:37:48 +01:00
|
|
|
locinfo->lc_category[LC_COLLATE].locale,
|
|
|
|
locinfo->lc_category[LC_CTYPE].locale,
|
|
|
|
locinfo->lc_category[LC_MONETARY].locale,
|
|
|
|
locinfo->lc_category[LC_NUMERIC].locale,
|
|
|
|
locinfo->lc_category[LC_TIME].locale);
|
2010-04-19 10:58:51 +02:00
|
|
|
|
|
|
|
return current_lc_all;
|
|
|
|
}
|
|
|
|
|
2010-04-15 14:25:13 +02:00
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _Getdays (MSVCRT.@)
|
|
|
|
*/
|
2011-12-07 13:49:09 +01:00
|
|
|
char* CDECL _Getdays(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
__lc_time_data *cur = get_locinfo()->lc_time_curr;
|
2019-12-04 15:29:59 +01:00
|
|
|
int i, len, size = 0;
|
2011-12-07 13:49:09 +01:00
|
|
|
char *out;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2019-12-04 15:29:59 +01:00
|
|
|
for(i=0; i<7; i++) {
|
|
|
|
size += strlen(cur->str.names.short_wday[i]) + 1;
|
|
|
|
size += strlen(cur->str.names.wday[i]) + 1;
|
|
|
|
}
|
2020-12-01 13:51:32 +01:00
|
|
|
out = malloc(size+1);
|
2011-12-07 13:49:09 +01:00
|
|
|
if(!out)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
size = 0;
|
|
|
|
for(i=0; i<7; i++) {
|
|
|
|
out[size++] = ':';
|
2012-04-11 15:22:12 +02:00
|
|
|
len = strlen(cur->str.names.short_wday[i]);
|
|
|
|
memcpy(&out[size], cur->str.names.short_wday[i], len);
|
2011-12-07 13:49:09 +01:00
|
|
|
size += len;
|
|
|
|
|
|
|
|
out[size++] = ':';
|
2012-04-11 15:22:12 +02:00
|
|
|
len = strlen(cur->str.names.wday[i]);
|
|
|
|
memcpy(&out[size], cur->str.names.wday[i], len);
|
2011-12-07 13:49:09 +01:00
|
|
|
size += len;
|
|
|
|
}
|
2011-12-28 16:29:07 +01:00
|
|
|
out[size] = '\0';
|
2011-12-07 13:49:09 +01:00
|
|
|
|
|
|
|
return out;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2018-01-04 05:33:01 +01:00
|
|
|
#if _MSVCR_VER >= 110
|
2015-06-09 01:24:00 +02:00
|
|
|
/*********************************************************************
|
2018-01-10 07:21:46 +01:00
|
|
|
* _W_Getdays (MSVCR110.@)
|
2015-06-09 01:24:00 +02:00
|
|
|
*/
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t* CDECL _W_Getdays(void)
|
2015-06-09 01:24:00 +02:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
__lc_time_data *cur = get_locinfo()->lc_time_curr;
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t *out;
|
2019-12-04 15:30:03 +01:00
|
|
|
int i, len, size = 0;
|
2015-06-09 01:24:00 +02:00
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2019-12-04 15:30:03 +01:00
|
|
|
for(i=0; i<7; i++) {
|
2020-12-03 19:10:54 +01:00
|
|
|
size += wcslen(cur->wstr.names.short_wday[i]) + 1;
|
|
|
|
size += wcslen(cur->wstr.names.wday[i]) + 1;
|
2019-12-04 15:30:03 +01:00
|
|
|
}
|
2020-12-01 13:51:32 +01:00
|
|
|
out = malloc((size+1)*sizeof(*out));
|
2015-06-09 01:24:00 +02:00
|
|
|
if(!out)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
size = 0;
|
|
|
|
for(i=0; i<7; i++) {
|
|
|
|
out[size++] = ':';
|
2020-12-03 19:10:54 +01:00
|
|
|
len = wcslen(cur->wstr.names.short_wday[i]);
|
2015-06-09 01:24:00 +02:00
|
|
|
memcpy(&out[size], cur->wstr.names.short_wday[i], len*sizeof(*out));
|
|
|
|
size += len;
|
|
|
|
|
|
|
|
out[size++] = ':';
|
2020-12-03 19:10:54 +01:00
|
|
|
len = wcslen(cur->wstr.names.wday[i]);
|
2015-06-09 01:24:00 +02:00
|
|
|
memcpy(&out[size], cur->wstr.names.wday[i], len*sizeof(*out));
|
|
|
|
size += len;
|
|
|
|
}
|
|
|
|
out[size] = '\0';
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
2018-01-04 05:33:01 +01:00
|
|
|
#endif
|
2015-06-09 01:24:00 +02:00
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _Getmonths (MSVCRT.@)
|
|
|
|
*/
|
2011-12-07 13:49:47 +01:00
|
|
|
char* CDECL _Getmonths(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
__lc_time_data *cur = get_locinfo()->lc_time_curr;
|
2019-12-04 15:30:08 +01:00
|
|
|
int i, len, size = 0;
|
2011-12-07 13:49:47 +01:00
|
|
|
char *out;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2019-12-04 15:30:08 +01:00
|
|
|
for(i=0; i<12; i++) {
|
|
|
|
size += strlen(cur->str.names.short_mon[i]) + 1;
|
|
|
|
size += strlen(cur->str.names.mon[i]) + 1;
|
|
|
|
}
|
2020-12-01 13:51:32 +01:00
|
|
|
out = malloc(size+1);
|
2011-12-07 13:49:47 +01:00
|
|
|
if(!out)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
size = 0;
|
|
|
|
for(i=0; i<12; i++) {
|
|
|
|
out[size++] = ':';
|
2012-04-11 15:22:12 +02:00
|
|
|
len = strlen(cur->str.names.short_mon[i]);
|
|
|
|
memcpy(&out[size], cur->str.names.short_mon[i], len);
|
2011-12-07 13:49:47 +01:00
|
|
|
size += len;
|
|
|
|
|
|
|
|
out[size++] = ':';
|
2012-04-11 15:22:12 +02:00
|
|
|
len = strlen(cur->str.names.mon[i]);
|
|
|
|
memcpy(&out[size], cur->str.names.mon[i], len);
|
2011-12-07 13:49:47 +01:00
|
|
|
size += len;
|
|
|
|
}
|
2011-12-28 16:29:07 +01:00
|
|
|
out[size] = '\0';
|
2011-12-07 13:49:47 +01:00
|
|
|
|
|
|
|
return out;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2018-01-04 05:33:01 +01:00
|
|
|
#if _MSVCR_VER >= 110
|
2015-06-09 02:10:01 +02:00
|
|
|
/*********************************************************************
|
2018-01-10 07:21:46 +01:00
|
|
|
* _W_Getmonths (MSVCR110.@)
|
2015-06-09 02:10:01 +02:00
|
|
|
*/
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t* CDECL _W_Getmonths(void)
|
2015-06-09 02:10:01 +02:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
__lc_time_data *cur = get_locinfo()->lc_time_curr;
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t *out;
|
2019-12-04 15:30:13 +01:00
|
|
|
int i, len, size = 0;
|
2015-06-09 02:10:01 +02:00
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2019-12-04 15:30:13 +01:00
|
|
|
for(i=0; i<12; i++) {
|
2020-12-03 19:10:54 +01:00
|
|
|
size += wcslen(cur->wstr.names.short_mon[i]) + 1;
|
|
|
|
size += wcslen(cur->wstr.names.mon[i]) + 1;
|
2019-12-04 15:30:13 +01:00
|
|
|
}
|
2020-12-01 13:51:32 +01:00
|
|
|
out = malloc((size+1)*sizeof(*out));
|
2015-06-09 02:10:01 +02:00
|
|
|
if(!out)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
size = 0;
|
|
|
|
for(i=0; i<12; i++) {
|
|
|
|
out[size++] = ':';
|
2020-12-03 19:10:54 +01:00
|
|
|
len = wcslen(cur->wstr.names.short_mon[i]);
|
2015-06-09 02:10:01 +02:00
|
|
|
memcpy(&out[size], cur->wstr.names.short_mon[i], len*sizeof(*out));
|
|
|
|
size += len;
|
|
|
|
|
|
|
|
out[size++] = ':';
|
2020-12-03 19:10:54 +01:00
|
|
|
len = wcslen(cur->wstr.names.mon[i]);
|
2015-06-09 02:10:01 +02:00
|
|
|
memcpy(&out[size], cur->wstr.names.mon[i], len*sizeof(*out));
|
|
|
|
size += len;
|
|
|
|
}
|
|
|
|
out[size] = '\0';
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
2018-01-04 05:33:01 +01:00
|
|
|
#endif
|
2015-06-09 02:10:01 +02:00
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2005-06-22 20:07:31 +02:00
|
|
|
* _Gettnames (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2011-12-07 13:48:36 +01:00
|
|
|
void* CDECL _Gettnames(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
__lc_time_data *ret, *cur = get_locinfo()->lc_time_curr;
|
|
|
|
unsigned int i, len, size = sizeof(__lc_time_data);
|
2011-12-07 13:48:36 +01:00
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2018-07-26 00:05:52 +02:00
|
|
|
for(i=0; i<ARRAY_SIZE(cur->str.str); i++)
|
2012-04-11 15:22:12 +02:00
|
|
|
size += strlen(cur->str.str[i])+1;
|
2021-02-02 18:55:33 +01:00
|
|
|
#if _MSVCR_VER >= 110
|
|
|
|
for(i=0; i<ARRAY_SIZE(cur->wstr.wstr); i++)
|
|
|
|
size += (wcslen(cur->wstr.wstr[i]) + 1) * sizeof(wchar_t);
|
|
|
|
#endif
|
2011-12-07 13:48:36 +01:00
|
|
|
|
2020-12-01 13:51:32 +01:00
|
|
|
ret = malloc(size);
|
2011-12-07 13:48:36 +01:00
|
|
|
if(!ret)
|
|
|
|
return NULL;
|
2019-12-04 15:30:38 +01:00
|
|
|
memcpy(ret, cur, sizeof(*ret));
|
2011-12-07 13:48:36 +01:00
|
|
|
|
|
|
|
size = 0;
|
2018-07-26 00:05:52 +02:00
|
|
|
for(i=0; i<ARRAY_SIZE(cur->str.str); i++) {
|
2019-12-04 15:30:38 +01:00
|
|
|
len = strlen(cur->str.str[i])+1;
|
|
|
|
memcpy(&ret->data[size], cur->str.str[i], len);
|
2012-04-11 15:22:12 +02:00
|
|
|
ret->str.str[i] = &ret->data[size];
|
2019-12-04 15:30:38 +01:00
|
|
|
size += len;
|
2011-12-07 13:48:36 +01:00
|
|
|
}
|
2021-02-02 18:55:33 +01:00
|
|
|
#if _MSVCR_VER >= 110
|
|
|
|
for(i=0; i<ARRAY_SIZE(cur->wstr.wstr); i++) {
|
|
|
|
len = (wcslen(cur->wstr.wstr[i]) + 1) * sizeof(wchar_t);
|
|
|
|
memcpy(&ret->data[size], cur->wstr.wstr[i], len);
|
|
|
|
ret->wstr.wstr[i] = (wchar_t*)&ret->data[size];
|
|
|
|
size += len;
|
|
|
|
}
|
|
|
|
#endif
|
2011-12-07 13:48:36 +01:00
|
|
|
|
|
|
|
return ret;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2018-01-04 05:33:01 +01:00
|
|
|
#if _MSVCR_VER >= 110
|
2016-01-20 11:42:14 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _W_Gettnames (MSVCR110.@)
|
|
|
|
*/
|
|
|
|
void* CDECL _W_Gettnames(void)
|
|
|
|
{
|
|
|
|
return _Gettnames();
|
|
|
|
}
|
2018-01-04 05:33:01 +01:00
|
|
|
#endif
|
2016-01-20 11:42:14 +01:00
|
|
|
|
2003-02-11 23:11:17 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* __crtLCMapStringA (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL __crtLCMapStringA(
|
2003-02-11 23:11:17 +01:00
|
|
|
LCID lcid, DWORD mapflags, const char* src, int srclen, char* dst,
|
|
|
|
int dstlen, unsigned int codepage, int xflag
|
|
|
|
) {
|
2020-07-16 14:46:35 +02:00
|
|
|
WCHAR buf_in[32], *in = buf_in;
|
|
|
|
WCHAR buf_out[32], *out = buf_out;
|
|
|
|
int in_len, out_len, r;
|
|
|
|
|
2022-02-08 19:38:40 +01:00
|
|
|
TRACE("(lcid %lx, flags %lx, %s(%d), %p(%d), %x, %d), partial stub!\n",
|
2020-07-16 14:46:35 +02:00
|
|
|
lcid, mapflags, src, srclen, dst, dstlen, codepage, xflag);
|
|
|
|
|
|
|
|
in_len = MultiByteToWideChar(codepage, MB_ERR_INVALID_CHARS, src, srclen, NULL, 0);
|
|
|
|
if (!in_len) return 0;
|
|
|
|
if (in_len > ARRAY_SIZE(buf_in))
|
|
|
|
{
|
2020-12-01 13:51:32 +01:00
|
|
|
in = malloc(in_len * sizeof(WCHAR));
|
2020-07-16 14:46:35 +02:00
|
|
|
if (!in) return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = MultiByteToWideChar(codepage, MB_ERR_INVALID_CHARS, src, srclen, in, in_len);
|
|
|
|
if (!r) goto done;
|
|
|
|
|
|
|
|
if (mapflags & LCMAP_SORTKEY)
|
|
|
|
{
|
|
|
|
r = LCMapStringW(lcid, mapflags, in, in_len, (WCHAR*)dst, dstlen);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = LCMapStringW(lcid, mapflags, in, in_len, NULL, 0);
|
|
|
|
if (!r) goto done;
|
|
|
|
out_len = r;
|
|
|
|
if (r > ARRAY_SIZE(buf_out))
|
|
|
|
{
|
2020-12-01 13:51:32 +01:00
|
|
|
out = malloc(r * sizeof(WCHAR));
|
2020-07-16 14:46:35 +02:00
|
|
|
if (!out)
|
|
|
|
{
|
|
|
|
r = 0;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
r = LCMapStringW(lcid, mapflags, in, in_len, out, out_len);
|
|
|
|
if (!r) goto done;
|
|
|
|
|
|
|
|
r = WideCharToMultiByte(codepage, 0, out, out_len, dst, dstlen, NULL, NULL);
|
|
|
|
|
|
|
|
done:
|
2020-12-01 13:51:32 +01:00
|
|
|
if (in != buf_in) free(in);
|
|
|
|
if (out != buf_out) free(out);
|
2020-07-16 14:46:35 +02:00
|
|
|
return r;
|
2003-02-11 23:11:17 +01:00
|
|
|
}
|
2003-06-04 22:24:56 +02:00
|
|
|
|
2010-06-22 12:26:23 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* __crtLCMapStringW (MSVCRT.@)
|
|
|
|
*/
|
2020-11-27 14:16:49 +01:00
|
|
|
int CDECL __crtLCMapStringW(LCID lcid, DWORD mapflags, const wchar_t *src,
|
|
|
|
int srclen, wchar_t *dst, int dstlen, unsigned int codepage, int xflag)
|
2010-06-22 12:26:23 +02:00
|
|
|
{
|
2022-02-08 19:38:40 +01:00
|
|
|
FIXME("(lcid %lx, flags %lx, %s(%d), %p(%d), %x, %d), partial stub!\n",
|
2010-06-22 12:26:23 +02:00
|
|
|
lcid, mapflags, debugstr_w(src), srclen, dst, dstlen, codepage, xflag);
|
|
|
|
|
|
|
|
return LCMapStringW(lcid, mapflags, src, srclen, dst, dstlen);
|
|
|
|
}
|
|
|
|
|
2007-09-19 17:53:06 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* __crtCompareStringA (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL __crtCompareStringA( LCID lcid, DWORD flags, const char *src1, int len1,
|
|
|
|
const char *src2, int len2 )
|
|
|
|
{
|
2022-02-08 19:38:40 +01:00
|
|
|
FIXME("(lcid %lx, flags %lx, %s(%d), %s(%d), partial stub\n",
|
2007-09-19 17:53:06 +02:00
|
|
|
lcid, flags, debugstr_a(src1), len1, debugstr_a(src2), len2 );
|
|
|
|
/* FIXME: probably not entirely right */
|
|
|
|
return CompareStringA( lcid, flags, src1, len1, src2, len2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __crtCompareStringW (MSVCRT.@)
|
|
|
|
*/
|
2020-11-27 14:16:49 +01:00
|
|
|
int CDECL __crtCompareStringW( LCID lcid, DWORD flags, const wchar_t *src1, int len1,
|
|
|
|
const wchar_t *src2, int len2 )
|
2007-09-19 17:53:06 +02:00
|
|
|
{
|
2022-02-08 19:38:40 +01:00
|
|
|
FIXME("(lcid %lx, flags %lx, %s(%d), %s(%d), partial stub\n",
|
2007-09-19 17:53:06 +02:00
|
|
|
lcid, flags, debugstr_w(src1), len1, debugstr_w(src2), len2 );
|
|
|
|
/* FIXME: probably not entirely right */
|
|
|
|
return CompareStringW( lcid, flags, src1, len1, src2, len2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __crtGetLocaleInfoW (MSVCRT.@)
|
|
|
|
*/
|
2020-11-27 14:16:49 +01:00
|
|
|
int CDECL __crtGetLocaleInfoW( LCID lcid, LCTYPE type, wchar_t *buffer, int len )
|
2007-09-19 17:53:06 +02:00
|
|
|
{
|
2022-02-08 19:38:40 +01:00
|
|
|
FIXME("(lcid %lx, type %lx, %p(%d), partial stub\n", lcid, type, buffer, len );
|
2007-09-19 17:53:06 +02:00
|
|
|
/* FIXME: probably not entirely right */
|
|
|
|
return GetLocaleInfoW( lcid, type, buffer, len );
|
|
|
|
}
|
|
|
|
|
2018-01-04 05:33:01 +01:00
|
|
|
#if _MSVCR_VER >= 110
|
2015-06-22 12:52:30 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* __crtGetLocaleInfoEx (MSVC110.@)
|
|
|
|
*/
|
2020-11-27 14:16:49 +01:00
|
|
|
int CDECL __crtGetLocaleInfoEx( const WCHAR *locale, LCTYPE type, wchar_t *buffer, int len )
|
2015-06-22 12:52:30 +02:00
|
|
|
{
|
2022-02-08 19:38:40 +01:00
|
|
|
TRACE("(%s, %lx, %p, %d)\n", debugstr_w(locale), type, buffer, len);
|
2015-06-22 12:52:30 +02:00
|
|
|
return GetLocaleInfoEx(locale, type, buffer, len);
|
|
|
|
}
|
2018-01-04 05:33:01 +01:00
|
|
|
#endif
|
2015-06-22 12:52:30 +02:00
|
|
|
|
2010-04-19 10:58:19 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* __crtGetStringTypeW(MSVCRT.@)
|
|
|
|
*
|
|
|
|
* This function was accepting different number of arguments in older
|
|
|
|
* versions of msvcrt.
|
|
|
|
*/
|
|
|
|
BOOL CDECL __crtGetStringTypeW(DWORD unk, DWORD type,
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t *buffer, int len, WORD *out)
|
2010-04-19 10:58:19 +02:00
|
|
|
{
|
2022-02-08 19:38:40 +01:00
|
|
|
FIXME("(unk %lx, type %lx, wstr %p(%d), %p) partial stub\n",
|
2010-04-19 10:58:19 +02:00
|
|
|
unk, type, buffer, len, out);
|
|
|
|
|
|
|
|
return GetStringTypeW(type, buffer, len, out);
|
|
|
|
}
|
|
|
|
|
2003-06-04 22:24:56 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* localeconv (MSVCRT.@)
|
|
|
|
*/
|
2020-11-26 19:19:24 +01:00
|
|
|
struct lconv* CDECL localeconv(void)
|
2009-10-22 22:26:45 +02:00
|
|
|
{
|
2011-05-24 17:22:42 +02:00
|
|
|
return get_locinfo()->lconv;
|
2003-06-04 22:24:56 +02:00
|
|
|
}
|
2003-06-06 20:11:23 +02:00
|
|
|
|
2004-01-13 06:45:05 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* __lconv_init (MSVCRT.@)
|
|
|
|
*/
|
2010-06-11 01:57:53 +02:00
|
|
|
int CDECL __lconv_init(void)
|
2004-01-13 06:45:05 +01:00
|
|
|
{
|
2009-10-22 22:26:45 +02:00
|
|
|
/* this is used to make chars unsigned */
|
2020-11-18 17:26:10 +01:00
|
|
|
cloc_lconv.int_frac_digits = (char)UCHAR_MAX;
|
|
|
|
cloc_lconv.frac_digits = (char)UCHAR_MAX;
|
|
|
|
cloc_lconv.p_cs_precedes = (char)UCHAR_MAX;
|
|
|
|
cloc_lconv.p_sep_by_space = (char)UCHAR_MAX;
|
|
|
|
cloc_lconv.n_cs_precedes = (char)UCHAR_MAX;
|
|
|
|
cloc_lconv.n_sep_by_space = (char)UCHAR_MAX;
|
|
|
|
cloc_lconv.p_sign_posn = (char)UCHAR_MAX;
|
|
|
|
cloc_lconv.n_sign_posn = (char)UCHAR_MAX;
|
2010-06-11 01:57:53 +02:00
|
|
|
return 0;
|
2004-01-13 06:45:05 +01:00
|
|
|
}
|
2009-04-15 15:18:19 +02:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* ___lc_handle_func (MSVCRT.@)
|
|
|
|
*/
|
2011-05-26 11:40:04 +02:00
|
|
|
LCID* CDECL ___lc_handle_func(void)
|
2009-04-15 15:18:19 +02:00
|
|
|
{
|
2020-11-20 12:35:52 +01:00
|
|
|
return (LCID *)get_locinfo()->lc_handle;
|
2009-04-15 15:18:19 +02:00
|
|
|
}
|
|
|
|
|
2018-01-04 05:33:01 +01:00
|
|
|
#if _MSVCR_VER >= 110
|
2015-06-17 11:46:42 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* ___lc_locale_name_func (MSVCR110.@)
|
|
|
|
*/
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t** CDECL ___lc_locale_name_func(void)
|
2015-06-17 11:46:42 +02:00
|
|
|
{
|
|
|
|
return get_locinfo()->lc_name;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-15 15:18:19 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* ___lc_codepage_func (MSVCRT.@)
|
|
|
|
*/
|
2011-12-21 15:59:09 +01:00
|
|
|
unsigned int CDECL ___lc_codepage_func(void)
|
2009-04-15 15:18:19 +02:00
|
|
|
{
|
2014-01-13 14:02:44 +01:00
|
|
|
return get_locinfo()->lc_codepage;
|
2009-04-15 15:18:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* ___lc_collate_cp_func (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL ___lc_collate_cp_func(void)
|
|
|
|
{
|
2011-05-24 17:22:42 +02:00
|
|
|
return get_locinfo()->lc_collate_cp;
|
2009-04-15 15:18:19 +02:00
|
|
|
}
|
2010-04-08 10:24:25 +02:00
|
|
|
|
2020-11-26 19:19:09 +01:00
|
|
|
/* INTERNAL: frees pthreadlocinfo struct */
|
|
|
|
void free_locinfo(pthreadlocinfo locinfo)
|
2010-04-08 10:24:25 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2011-05-24 17:22:42 +02:00
|
|
|
if(!locinfo)
|
2010-05-20 16:20:29 +02:00
|
|
|
return;
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
for(i=LC_MIN+1; i<=LC_MAX; i++) {
|
2020-11-18 17:25:50 +01:00
|
|
|
if(!locinfo->lc_category[i].refcount
|
2022-02-03 11:50:30 +01:00
|
|
|
|| !InterlockedDecrement((LONG *)locinfo->lc_category[i].refcount)) {
|
2020-12-01 13:51:32 +01:00
|
|
|
free(locinfo->lc_category[i].locale);
|
|
|
|
free(locinfo->lc_category[i].refcount);
|
2020-11-18 17:25:50 +01:00
|
|
|
}
|
|
|
|
if(!locinfo->lc_category[i].wrefcount
|
2022-02-03 11:50:30 +01:00
|
|
|
|| !InterlockedDecrement((LONG *)locinfo->lc_category[i].wrefcount)) {
|
2015-06-17 11:46:42 +02:00
|
|
|
#if _MSVCR_VER >= 110
|
2020-12-01 13:51:32 +01:00
|
|
|
free(locinfo->lc_name[i]);
|
2015-06-17 11:46:42 +02:00
|
|
|
#endif
|
2020-12-01 13:51:32 +01:00
|
|
|
free(locinfo->lc_category[i].wrefcount);
|
2020-11-18 17:25:50 +01:00
|
|
|
}
|
2010-04-08 10:24:25 +02:00
|
|
|
}
|
|
|
|
|
2020-11-18 17:26:10 +01:00
|
|
|
if(locinfo->lconv_num_refcount
|
2022-02-03 11:50:30 +01:00
|
|
|
&& !InterlockedDecrement((LONG *)locinfo->lconv_num_refcount)) {
|
2020-12-01 13:51:32 +01:00
|
|
|
free(locinfo->lconv->decimal_point);
|
|
|
|
free(locinfo->lconv->thousands_sep);
|
|
|
|
free(locinfo->lconv->grouping);
|
2020-11-18 17:26:10 +01:00
|
|
|
#if _MSVCR_VER >= 100
|
2020-12-01 13:51:32 +01:00
|
|
|
free(locinfo->lconv->_W_decimal_point);
|
|
|
|
free(locinfo->lconv->_W_thousands_sep);
|
2020-11-18 17:26:10 +01:00
|
|
|
#endif
|
2020-12-01 13:51:32 +01:00
|
|
|
free(locinfo->lconv_num_refcount);
|
2020-11-18 17:26:10 +01:00
|
|
|
}
|
|
|
|
if(locinfo->lconv_mon_refcount
|
2022-02-03 11:50:30 +01:00
|
|
|
&& !InterlockedDecrement((LONG *)locinfo->lconv_mon_refcount)) {
|
2020-12-01 13:51:32 +01:00
|
|
|
free(locinfo->lconv->int_curr_symbol);
|
|
|
|
free(locinfo->lconv->currency_symbol);
|
|
|
|
free(locinfo->lconv->mon_decimal_point);
|
|
|
|
free(locinfo->lconv->mon_thousands_sep);
|
|
|
|
free(locinfo->lconv->mon_grouping);
|
|
|
|
free(locinfo->lconv->positive_sign);
|
|
|
|
free(locinfo->lconv->negative_sign);
|
2016-05-04 14:29:50 +02:00
|
|
|
#if _MSVCR_VER >= 100
|
2020-12-01 13:51:32 +01:00
|
|
|
free(locinfo->lconv->_W_int_curr_symbol);
|
|
|
|
free(locinfo->lconv->_W_currency_symbol);
|
|
|
|
free(locinfo->lconv->_W_mon_decimal_point);
|
|
|
|
free(locinfo->lconv->_W_mon_thousands_sep);
|
|
|
|
free(locinfo->lconv->_W_positive_sign);
|
|
|
|
free(locinfo->lconv->_W_negative_sign);
|
2014-11-21 20:36:46 +01:00
|
|
|
#endif
|
2020-12-01 13:51:32 +01:00
|
|
|
free(locinfo->lconv_mon_refcount);
|
2020-11-18 17:26:10 +01:00
|
|
|
}
|
|
|
|
if(locinfo->lconv_intl_refcount
|
2022-02-03 11:50:30 +01:00
|
|
|
&& !InterlockedDecrement((LONG *)locinfo->lconv_intl_refcount)) {
|
2020-12-01 13:51:32 +01:00
|
|
|
free(locinfo->lconv_intl_refcount);
|
|
|
|
free(locinfo->lconv);
|
2010-04-08 10:24:25 +02:00
|
|
|
}
|
2011-05-24 17:22:42 +02:00
|
|
|
|
2020-11-18 17:26:05 +01:00
|
|
|
if(locinfo->ctype1_refcount
|
2022-02-03 11:50:30 +01:00
|
|
|
&& !InterlockedDecrement((LONG *)locinfo->ctype1_refcount)) {
|
2020-12-01 13:51:32 +01:00
|
|
|
free(locinfo->ctype1_refcount);
|
|
|
|
free(locinfo->ctype1);
|
|
|
|
free((void*)locinfo->pclmap);
|
|
|
|
free((void*)locinfo->pcumap);
|
2020-11-18 17:26:05 +01:00
|
|
|
}
|
2010-04-08 10:24:25 +02:00
|
|
|
|
2020-11-25 20:24:09 +01:00
|
|
|
if(locinfo->lc_time_curr && !InterlockedDecrement(&locinfo->lc_time_curr->refcount)
|
|
|
|
&& locinfo->lc_time_curr != &cloc_time_data)
|
2020-12-01 13:51:32 +01:00
|
|
|
free(locinfo->lc_time_curr);
|
2011-12-07 13:48:22 +01:00
|
|
|
|
2022-02-03 11:50:30 +01:00
|
|
|
if(InterlockedDecrement((LONG *)&locinfo->refcount))
|
2020-11-18 17:26:33 +01:00
|
|
|
return;
|
|
|
|
|
2020-12-01 13:51:32 +01:00
|
|
|
free(locinfo);
|
2011-05-24 17:22:42 +02:00
|
|
|
}
|
2010-04-08 10:24:25 +02:00
|
|
|
|
2020-11-26 19:19:13 +01:00
|
|
|
/* INTERNAL: frees pthreadmbcinfo struct */
|
|
|
|
void free_mbcinfo(pthreadmbcinfo mbcinfo)
|
2011-05-24 17:22:42 +02:00
|
|
|
{
|
|
|
|
if(!mbcinfo)
|
|
|
|
return;
|
|
|
|
|
2011-12-06 12:47:54 +01:00
|
|
|
if(InterlockedDecrement(&mbcinfo->refcount))
|
|
|
|
return;
|
|
|
|
|
2020-12-01 13:51:32 +01:00
|
|
|
free(mbcinfo);
|
2011-05-24 17:22:42 +02:00
|
|
|
}
|
|
|
|
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t CDECL get_current_locale_noalloc(_locale_t locale)
|
2020-11-10 16:58:49 +01:00
|
|
|
{
|
|
|
|
thread_data_t *data = msvcrt_get_thread_data();
|
|
|
|
|
2020-11-25 20:24:56 +01:00
|
|
|
update_thread_locale(data);
|
|
|
|
locale->locinfo = data->locinfo;
|
|
|
|
locale->mbcinfo = data->mbcinfo;
|
2020-11-10 16:58:49 +01:00
|
|
|
|
2020-11-25 20:24:34 +01:00
|
|
|
grab_locinfo(locale->locinfo);
|
2020-11-10 16:58:49 +01:00
|
|
|
InterlockedIncrement(&locale->mbcinfo->refcount);
|
|
|
|
return locale;
|
|
|
|
}
|
|
|
|
|
2020-11-26 19:19:18 +01:00
|
|
|
void CDECL free_locale_noalloc(_locale_t locale)
|
2020-11-10 16:58:49 +01:00
|
|
|
{
|
|
|
|
free_locinfo(locale->locinfo);
|
|
|
|
free_mbcinfo(locale->mbcinfo);
|
|
|
|
}
|
|
|
|
|
2013-03-28 12:56:38 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _get_current_locale (MSVCRT.@)
|
|
|
|
*/
|
2020-11-26 19:19:24 +01:00
|
|
|
_locale_t CDECL _get_current_locale(void)
|
2011-12-06 12:47:54 +01:00
|
|
|
{
|
2020-12-01 13:51:32 +01:00
|
|
|
_locale_t loc = malloc(sizeof(_locale_tstruct));
|
2011-12-06 12:47:54 +01:00
|
|
|
if(!loc)
|
|
|
|
return NULL;
|
|
|
|
|
2020-11-10 16:58:49 +01:00
|
|
|
return get_current_locale_noalloc(loc);
|
2011-12-06 12:47:54 +01:00
|
|
|
}
|
|
|
|
|
2013-03-28 12:56:38 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _free_locale (MSVCRT.@)
|
|
|
|
*/
|
2020-11-26 19:19:24 +01:00
|
|
|
void CDECL _free_locale(_locale_t locale)
|
2011-05-24 17:22:42 +02:00
|
|
|
{
|
|
|
|
if (!locale)
|
|
|
|
return;
|
|
|
|
|
2020-11-10 16:58:49 +01:00
|
|
|
free_locale_noalloc(locale);
|
2020-12-01 13:51:32 +01:00
|
|
|
free(locale);
|
2010-04-08 10:24:25 +02:00
|
|
|
}
|
|
|
|
|
2020-11-18 17:26:29 +01:00
|
|
|
static inline BOOL category_needs_update(int cat,
|
2020-11-26 19:19:09 +01:00
|
|
|
const threadlocinfo *locinfo, LCID lcid, unsigned short cp)
|
2015-09-24 16:16:16 +02:00
|
|
|
{
|
|
|
|
if(!locinfo) return TRUE;
|
|
|
|
return lcid!=locinfo->lc_handle[cat] || cp!=locinfo->lc_id[cat].wCodePage;
|
|
|
|
}
|
|
|
|
|
2020-11-26 19:19:09 +01:00
|
|
|
static __lc_time_data* create_time_data(LCID lcid)
|
2010-04-08 10:24:25 +02:00
|
|
|
{
|
2011-12-07 13:48:22 +01:00
|
|
|
static const DWORD time_data[] = {
|
|
|
|
LOCALE_SABBREVDAYNAME7, LOCALE_SABBREVDAYNAME1, LOCALE_SABBREVDAYNAME2,
|
|
|
|
LOCALE_SABBREVDAYNAME3, LOCALE_SABBREVDAYNAME4, LOCALE_SABBREVDAYNAME5,
|
|
|
|
LOCALE_SABBREVDAYNAME6,
|
|
|
|
LOCALE_SDAYNAME7, LOCALE_SDAYNAME1, LOCALE_SDAYNAME2, LOCALE_SDAYNAME3,
|
|
|
|
LOCALE_SDAYNAME4, LOCALE_SDAYNAME5, LOCALE_SDAYNAME6,
|
|
|
|
LOCALE_SABBREVMONTHNAME1, LOCALE_SABBREVMONTHNAME2, LOCALE_SABBREVMONTHNAME3,
|
|
|
|
LOCALE_SABBREVMONTHNAME4, LOCALE_SABBREVMONTHNAME5, LOCALE_SABBREVMONTHNAME6,
|
|
|
|
LOCALE_SABBREVMONTHNAME7, LOCALE_SABBREVMONTHNAME8, LOCALE_SABBREVMONTHNAME9,
|
|
|
|
LOCALE_SABBREVMONTHNAME10, LOCALE_SABBREVMONTHNAME11, LOCALE_SABBREVMONTHNAME12,
|
|
|
|
LOCALE_SMONTHNAME1, LOCALE_SMONTHNAME2, LOCALE_SMONTHNAME3, LOCALE_SMONTHNAME4,
|
|
|
|
LOCALE_SMONTHNAME5, LOCALE_SMONTHNAME6, LOCALE_SMONTHNAME7, LOCALE_SMONTHNAME8,
|
|
|
|
LOCALE_SMONTHNAME9, LOCALE_SMONTHNAME10, LOCALE_SMONTHNAME11, LOCALE_SMONTHNAME12,
|
|
|
|
LOCALE_S1159, LOCALE_S2359,
|
|
|
|
LOCALE_SSHORTDATE, LOCALE_SLONGDATE,
|
|
|
|
LOCALE_STIMEFORMAT
|
|
|
|
};
|
2010-04-15 14:26:17 +02:00
|
|
|
|
2020-11-26 19:19:09 +01:00
|
|
|
__lc_time_data *cur;
|
2019-12-04 15:29:55 +01:00
|
|
|
int i, ret, size;
|
|
|
|
|
2020-11-26 19:19:09 +01:00
|
|
|
size = sizeof(__lc_time_data);
|
2019-12-04 15:29:55 +01:00
|
|
|
for(i=0; i<ARRAY_SIZE(time_data); i++) {
|
2019-12-04 16:22:14 +01:00
|
|
|
ret = GetLocaleInfoA(lcid, time_data[i], NULL, 0);
|
|
|
|
if(!ret)
|
|
|
|
return NULL;
|
|
|
|
size += ret;
|
2019-12-04 15:29:55 +01:00
|
|
|
|
2021-02-02 18:55:12 +01:00
|
|
|
#if _MSVCR_VER == 0 || _MSVCR_VER >= 100
|
2019-12-04 16:22:14 +01:00
|
|
|
ret = GetLocaleInfoW(lcid, time_data[i], NULL, 0);
|
|
|
|
if(!ret)
|
|
|
|
return NULL;
|
2020-11-27 14:16:49 +01:00
|
|
|
size += ret*sizeof(wchar_t);
|
2021-02-02 18:55:12 +01:00
|
|
|
#endif
|
2019-12-04 15:29:55 +01:00
|
|
|
}
|
|
|
|
#if _MSVCR_VER >= 110
|
2020-11-27 14:16:49 +01:00
|
|
|
size += LCIDToLocaleName(lcid, NULL, 0, 0)*sizeof(wchar_t);
|
2019-12-04 15:29:55 +01:00
|
|
|
#endif
|
|
|
|
|
2020-12-01 13:51:32 +01:00
|
|
|
cur = malloc(size);
|
2019-12-04 15:29:55 +01:00
|
|
|
if(!cur)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
for(i=0; i<ARRAY_SIZE(time_data); i++) {
|
|
|
|
cur->str.str[i] = &cur->data[ret];
|
2019-12-04 16:22:14 +01:00
|
|
|
ret += GetLocaleInfoA(lcid, time_data[i], &cur->data[ret], size-ret);
|
2019-12-04 15:29:55 +01:00
|
|
|
}
|
2021-02-02 18:55:12 +01:00
|
|
|
#if _MSVCR_VER == 0 || _MSVCR_VER >= 100
|
2019-12-04 15:29:55 +01:00
|
|
|
for(i=0; i<ARRAY_SIZE(time_data); i++) {
|
2020-11-27 14:16:49 +01:00
|
|
|
cur->wstr.wstr[i] = (wchar_t*)&cur->data[ret];
|
2019-12-04 16:22:14 +01:00
|
|
|
ret += GetLocaleInfoW(lcid, time_data[i],
|
2020-11-27 14:16:49 +01:00
|
|
|
(wchar_t*)&cur->data[ret], size-ret)*sizeof(wchar_t);
|
2019-12-04 15:29:55 +01:00
|
|
|
}
|
2021-02-02 18:55:12 +01:00
|
|
|
#endif
|
2019-12-04 15:29:55 +01:00
|
|
|
#if _MSVCR_VER >= 110
|
2020-11-27 14:16:49 +01:00
|
|
|
cur->locname = (wchar_t*)&cur->data[ret];
|
|
|
|
LCIDToLocaleName(lcid, (wchar_t*)&cur->data[ret], (size-ret)/sizeof(wchar_t), 0);
|
2019-12-04 15:29:55 +01:00
|
|
|
#else
|
|
|
|
cur->lcid = lcid;
|
|
|
|
#endif
|
2020-11-18 17:26:15 +01:00
|
|
|
cur->unk = 1;
|
|
|
|
cur->refcount = 1;
|
2019-12-04 15:29:55 +01:00
|
|
|
|
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
2020-11-26 19:19:09 +01:00
|
|
|
static pthreadlocinfo create_locinfo(int category,
|
|
|
|
const char *locale, const threadlocinfo *old_locinfo)
|
2019-12-04 15:29:55 +01:00
|
|
|
{
|
|
|
|
static const char collate[] = "COLLATE=";
|
|
|
|
static const char ctype[] = "CTYPE=";
|
|
|
|
static const char monetary[] = "MONETARY=";
|
|
|
|
static const char numeric[] = "NUMERIC=";
|
|
|
|
static const char time[] = "TIME=";
|
|
|
|
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo locinfo;
|
2019-12-04 15:29:55 +01:00
|
|
|
LCID lcid[6] = { 0 };
|
2012-12-18 11:38:33 +01:00
|
|
|
unsigned short cp[6] = { 0 };
|
2018-05-09 17:36:17 +02:00
|
|
|
const char *locale_name[6] = { 0 };
|
2020-11-18 16:04:09 +01:00
|
|
|
int val, locale_len[6] = { 0 };
|
2010-04-15 14:24:53 +02:00
|
|
|
char buf[256];
|
2018-05-09 17:36:17 +02:00
|
|
|
BOOL sname;
|
2016-05-04 14:29:50 +02:00
|
|
|
#if _MSVCR_VER >= 100
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t wbuf[256];
|
2014-11-21 20:36:46 +01:00
|
|
|
#endif
|
2019-12-04 15:29:55 +01:00
|
|
|
int i;
|
2010-04-08 10:24:25 +02:00
|
|
|
|
|
|
|
TRACE("(%d %s)\n", category, locale);
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(category<LC_MIN || category>LC_MAX || !locale)
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
|
2012-12-18 11:38:33 +01:00
|
|
|
if(locale[0]=='C' && !locale[1]) {
|
|
|
|
lcid[0] = 0;
|
|
|
|
cp[0] = CP_ACP;
|
|
|
|
} else if (locale[0] == 'L' && locale[1] == 'C' && locale[2] == '_') {
|
2011-08-22 21:31:47 +02:00
|
|
|
const char *p;
|
2010-04-15 14:26:17 +02:00
|
|
|
|
|
|
|
while(1) {
|
|
|
|
locale += 3; /* LC_ */
|
|
|
|
if(!memcmp(locale, collate, sizeof(collate)-1)) {
|
2020-11-30 14:37:48 +01:00
|
|
|
i = LC_COLLATE;
|
2010-04-15 14:26:17 +02:00
|
|
|
locale += sizeof(collate)-1;
|
|
|
|
} else if(!memcmp(locale, ctype, sizeof(ctype)-1)) {
|
2020-11-30 14:37:48 +01:00
|
|
|
i = LC_CTYPE;
|
2010-04-15 14:26:17 +02:00
|
|
|
locale += sizeof(ctype)-1;
|
|
|
|
} else if(!memcmp(locale, monetary, sizeof(monetary)-1)) {
|
2020-11-30 14:37:48 +01:00
|
|
|
i = LC_MONETARY;
|
2010-04-15 14:26:17 +02:00
|
|
|
locale += sizeof(monetary)-1;
|
|
|
|
} else if(!memcmp(locale, numeric, sizeof(numeric)-1)) {
|
2020-11-30 14:37:48 +01:00
|
|
|
i = LC_NUMERIC;
|
2010-04-15 14:26:17 +02:00
|
|
|
locale += sizeof(numeric)-1;
|
|
|
|
} else if(!memcmp(locale, time, sizeof(time)-1)) {
|
2020-11-30 14:37:48 +01:00
|
|
|
i = LC_TIME;
|
2010-04-15 14:26:17 +02:00
|
|
|
locale += sizeof(time)-1;
|
|
|
|
} else
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
p = strchr(locale, ';');
|
2012-12-18 11:38:33 +01:00
|
|
|
if(locale[0]=='C' && (locale[1]==';' || locale[1]=='\0')) {
|
2010-04-19 10:58:10 +02:00
|
|
|
lcid[i] = 0;
|
2012-12-18 11:38:33 +01:00
|
|
|
cp[i] = CP_ACP;
|
|
|
|
} else if(p) {
|
2010-04-15 14:26:17 +02:00
|
|
|
memcpy(buf, locale, p-locale);
|
2011-01-15 09:28:24 +01:00
|
|
|
buf[p-locale] = '\0';
|
2020-11-26 19:19:24 +01:00
|
|
|
lcid[i] = locale_to_LCID(buf, &cp[i], &sname);
|
2018-05-09 17:36:17 +02:00
|
|
|
if(sname) {
|
|
|
|
locale_name[i] = locale;
|
|
|
|
locale_len[i] = p-locale;
|
|
|
|
}
|
|
|
|
} else {
|
2020-11-26 19:19:24 +01:00
|
|
|
lcid[i] = locale_to_LCID(locale, &cp[i], &sname);
|
2018-05-09 17:36:17 +02:00
|
|
|
if(sname) {
|
|
|
|
locale_name[i] = locale;
|
|
|
|
locale_len[i] = strlen(locale);
|
|
|
|
}
|
|
|
|
}
|
2010-04-15 14:26:17 +02:00
|
|
|
|
2010-04-19 10:58:10 +02:00
|
|
|
if(lcid[i] == -1)
|
2010-04-15 14:26:17 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if(!p || *(p+1)!='L' || *(p+2)!='C' || *(p+3)!='_')
|
|
|
|
break;
|
|
|
|
|
2010-04-19 10:58:10 +02:00
|
|
|
locale = p+1;
|
2010-04-15 14:26:17 +02:00
|
|
|
}
|
2010-04-15 14:25:13 +02:00
|
|
|
} else {
|
2020-11-26 19:19:24 +01:00
|
|
|
lcid[0] = locale_to_LCID(locale, &cp[0], &sname);
|
2010-04-19 10:58:10 +02:00
|
|
|
if(lcid[0] == -1)
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
2018-05-09 17:36:17 +02:00
|
|
|
if(sname) {
|
|
|
|
locale_name[0] = locale;
|
|
|
|
locale_len[0] = strlen(locale);
|
|
|
|
}
|
2010-04-08 10:24:25 +02:00
|
|
|
|
2012-12-18 11:38:33 +01:00
|
|
|
for(i=1; i<6; i++) {
|
2010-04-15 14:26:17 +02:00
|
|
|
lcid[i] = lcid[0];
|
2012-12-18 11:38:33 +01:00
|
|
|
cp[i] = cp[0];
|
2018-05-09 17:36:17 +02:00
|
|
|
locale_name[i] = locale_name[0];
|
|
|
|
locale_len[i] = locale_len[0];
|
2012-12-18 11:38:33 +01:00
|
|
|
}
|
2010-04-15 14:26:17 +02:00
|
|
|
}
|
|
|
|
|
2020-11-18 17:26:29 +01:00
|
|
|
for(i=1; i<6; i++) {
|
2020-11-30 14:37:48 +01:00
|
|
|
if(category!=LC_ALL && category!=i) {
|
2020-11-18 17:26:29 +01:00
|
|
|
if(old_locinfo) {
|
|
|
|
lcid[i] = old_locinfo->lc_handle[i];
|
|
|
|
cp[i] = old_locinfo->lc_id[i].wCodePage;
|
|
|
|
} else {
|
|
|
|
lcid[i] = 0;
|
|
|
|
cp[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-01 13:51:32 +01:00
|
|
|
locinfo = malloc(sizeof(threadlocinfo));
|
2015-09-24 16:15:54 +02:00
|
|
|
if(!locinfo)
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
|
2020-11-26 19:19:09 +01:00
|
|
|
memset(locinfo, 0, sizeof(threadlocinfo));
|
2015-09-24 16:15:54 +02:00
|
|
|
locinfo->refcount = 1;
|
2010-04-08 10:24:25 +02:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(locale_name[LC_COLLATE] &&
|
|
|
|
!init_category_name(locale_name[LC_COLLATE],
|
|
|
|
locale_len[LC_COLLATE], locinfo, LC_COLLATE)) {
|
2018-05-09 17:36:17 +02:00
|
|
|
free_locinfo(locinfo);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!category_needs_update(LC_COLLATE, old_locinfo,
|
|
|
|
lcid[LC_COLLATE], cp[LC_COLLATE])) {
|
|
|
|
copy_threadlocinfo_category(locinfo, old_locinfo, LC_COLLATE);
|
2020-11-18 17:25:54 +01:00
|
|
|
locinfo->lc_collate_cp = old_locinfo->lc_collate_cp;
|
2020-11-30 14:37:48 +01:00
|
|
|
} else if(lcid[LC_COLLATE]) {
|
|
|
|
if(!update_threadlocinfo_category(lcid[LC_COLLATE],
|
|
|
|
cp[LC_COLLATE], locinfo, LC_COLLATE)) {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2011-12-06 12:48:09 +01:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
locinfo->lc_collate_cp = locinfo->lc_id[LC_COLLATE].wCodePage;
|
2020-11-18 17:25:39 +01:00
|
|
|
} else {
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!init_category_name("C", 1, locinfo, LC_COLLATE)) {
|
2020-11-18 17:25:39 +01:00
|
|
|
free_locinfo(locinfo);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2010-04-08 10:24:25 +02:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(locale_name[LC_CTYPE] &&
|
|
|
|
!init_category_name(locale_name[LC_CTYPE],
|
|
|
|
locale_len[LC_CTYPE], locinfo, LC_CTYPE)) {
|
2018-05-09 17:36:17 +02:00
|
|
|
free_locinfo(locinfo);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!category_needs_update(LC_CTYPE, old_locinfo,
|
|
|
|
lcid[LC_CTYPE], cp[LC_CTYPE])) {
|
|
|
|
copy_threadlocinfo_category(locinfo, old_locinfo, LC_CTYPE);
|
2020-11-18 17:26:05 +01:00
|
|
|
locinfo->lc_codepage = old_locinfo->lc_codepage;
|
|
|
|
locinfo->lc_clike = old_locinfo->lc_clike;
|
|
|
|
locinfo->mb_cur_max = old_locinfo->mb_cur_max;
|
|
|
|
locinfo->ctype1 = old_locinfo->ctype1;
|
|
|
|
locinfo->ctype1_refcount = old_locinfo->ctype1_refcount;
|
|
|
|
locinfo->pctype = old_locinfo->pctype;
|
|
|
|
locinfo->pclmap = old_locinfo->pclmap;
|
|
|
|
locinfo->pcumap = old_locinfo->pcumap;
|
|
|
|
if(locinfo->ctype1_refcount)
|
2022-02-03 11:50:30 +01:00
|
|
|
InterlockedIncrement((LONG *)locinfo->ctype1_refcount);
|
2020-11-30 14:37:48 +01:00
|
|
|
} else if(lcid[LC_CTYPE]) {
|
2012-12-18 11:38:33 +01:00
|
|
|
CPINFO cp_info;
|
2011-03-31 17:07:58 +02:00
|
|
|
int j;
|
2010-04-08 10:24:25 +02:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!update_threadlocinfo_category(lcid[LC_CTYPE],
|
|
|
|
cp[LC_CTYPE], locinfo, LC_CTYPE)) {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
locinfo->lc_codepage = locinfo->lc_id[LC_CTYPE].wCodePage;
|
2015-09-24 16:15:54 +02:00
|
|
|
locinfo->lc_clike = 1;
|
|
|
|
if(!GetCPInfo(locinfo->lc_codepage, &cp_info)) {
|
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2015-09-24 16:15:54 +02:00
|
|
|
locinfo->mb_cur_max = cp_info.MaxCharSize;
|
2010-04-08 10:24:25 +02:00
|
|
|
|
2020-12-01 13:51:32 +01:00
|
|
|
locinfo->ctype1_refcount = malloc(sizeof(int));
|
2020-11-18 17:26:05 +01:00
|
|
|
if(!locinfo->ctype1_refcount) {
|
|
|
|
free_locinfo(locinfo);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
*locinfo->ctype1_refcount = 1;
|
|
|
|
|
2020-12-01 13:51:32 +01:00
|
|
|
locinfo->ctype1 = malloc(sizeof(short[257]));
|
|
|
|
locinfo->pclmap = malloc(sizeof(char[256]));
|
|
|
|
locinfo->pcumap = malloc(sizeof(char[256]));
|
2020-11-18 17:26:05 +01:00
|
|
|
if(!locinfo->ctype1 || !locinfo->pclmap || !locinfo->pcumap) {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-09-24 16:15:54 +02:00
|
|
|
locinfo->ctype1[0] = 0;
|
|
|
|
locinfo->pctype = locinfo->ctype1+1;
|
2010-04-08 10:24:25 +02:00
|
|
|
|
|
|
|
buf[1] = buf[2] = '\0';
|
|
|
|
for(i=1; i<257; i++) {
|
|
|
|
buf[0] = i-1;
|
|
|
|
|
2011-10-18 15:22:46 +02:00
|
|
|
/* builtin GetStringTypeA doesn't set output to 0 on invalid input */
|
2015-09-24 16:15:54 +02:00
|
|
|
locinfo->ctype1[i] = 0;
|
2011-10-18 15:22:46 +02:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
GetStringTypeA(lcid[LC_CTYPE], CT_CTYPE1, buf,
|
2015-09-24 16:15:54 +02:00
|
|
|
1, locinfo->ctype1+i);
|
2010-04-08 10:24:25 +02:00
|
|
|
}
|
2011-03-31 17:07:58 +02:00
|
|
|
|
2012-12-18 11:38:33 +01:00
|
|
|
for(i=0; cp_info.LeadByte[i+1]!=0; i+=2)
|
|
|
|
for(j=cp_info.LeadByte[i]; j<=cp_info.LeadByte[i+1]; j++)
|
2020-12-01 13:51:51 +01:00
|
|
|
locinfo->ctype1[j+1] |= _LEADBYTE;
|
2015-06-17 11:46:42 +02:00
|
|
|
|
2015-09-24 16:15:54 +02:00
|
|
|
for(i=0; i<256; i++) {
|
2020-12-01 13:51:51 +01:00
|
|
|
if(locinfo->pctype[i] & _LEADBYTE)
|
2015-09-24 16:15:54 +02:00
|
|
|
buf[i] = ' ';
|
|
|
|
else
|
|
|
|
buf[i] = i;
|
|
|
|
}
|
2010-04-08 10:24:25 +02:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
LCMapStringA(lcid[LC_CTYPE], LCMAP_LOWERCASE, buf, 256,
|
2015-09-24 16:15:54 +02:00
|
|
|
(char*)locinfo->pclmap, 256);
|
2020-11-30 14:37:48 +01:00
|
|
|
LCMapStringA(lcid[LC_CTYPE], LCMAP_UPPERCASE, buf, 256,
|
2015-09-24 16:15:54 +02:00
|
|
|
(char*)locinfo->pcumap, 256);
|
2011-06-03 15:28:46 +02:00
|
|
|
} else {
|
2015-09-24 16:15:54 +02:00
|
|
|
locinfo->lc_clike = 1;
|
|
|
|
locinfo->mb_cur_max = 1;
|
|
|
|
locinfo->pctype = MSVCRT__ctype+1;
|
2020-11-18 17:26:05 +01:00
|
|
|
locinfo->pclmap = cloc_clmap;
|
|
|
|
locinfo->pcumap = cloc_cumap;
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!init_category_name("C", 1, locinfo, LC_CTYPE)) {
|
2020-11-18 17:25:39 +01:00
|
|
|
free_locinfo(locinfo);
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-06-03 15:28:46 +02:00
|
|
|
}
|
2010-04-08 10:24:25 +02:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!category_needs_update(LC_MONETARY, old_locinfo,
|
|
|
|
lcid[LC_MONETARY], cp[LC_MONETARY]) &&
|
|
|
|
!category_needs_update(LC_NUMERIC, old_locinfo,
|
|
|
|
lcid[LC_NUMERIC], cp[LC_NUMERIC])) {
|
2020-11-18 17:26:10 +01:00
|
|
|
locinfo->lconv = old_locinfo->lconv;
|
|
|
|
locinfo->lconv_intl_refcount = old_locinfo->lconv_intl_refcount;
|
|
|
|
if(locinfo->lconv_intl_refcount)
|
2022-02-03 11:50:30 +01:00
|
|
|
InterlockedIncrement((LONG *)locinfo->lconv_intl_refcount);
|
2020-11-30 14:37:48 +01:00
|
|
|
} else if(lcid[LC_MONETARY] || lcid[LC_NUMERIC]) {
|
2020-12-01 13:51:32 +01:00
|
|
|
locinfo->lconv = malloc(sizeof(struct lconv));
|
|
|
|
locinfo->lconv_intl_refcount = malloc(sizeof(int));
|
2020-11-18 17:26:10 +01:00
|
|
|
if(!locinfo->lconv || !locinfo->lconv_intl_refcount) {
|
2020-12-01 13:51:32 +01:00
|
|
|
free(locinfo->lconv);
|
|
|
|
free(locinfo->lconv_intl_refcount);
|
2020-11-18 17:26:10 +01:00
|
|
|
locinfo->lconv = NULL;
|
|
|
|
locinfo->lconv_intl_refcount = NULL;
|
|
|
|
free_locinfo(locinfo);
|
|
|
|
return NULL;
|
|
|
|
}
|
2020-11-26 19:19:05 +01:00
|
|
|
memset(locinfo->lconv, 0, sizeof(struct lconv));
|
2020-11-18 17:26:10 +01:00
|
|
|
*locinfo->lconv_intl_refcount = 1;
|
|
|
|
} else {
|
|
|
|
locinfo->lconv = &cloc_lconv;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(locale_name[LC_MONETARY] &&
|
|
|
|
!init_category_name(locale_name[LC_MONETARY],
|
|
|
|
locale_len[LC_MONETARY], locinfo, LC_MONETARY)) {
|
2018-05-09 17:36:17 +02:00
|
|
|
free_locinfo(locinfo);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!category_needs_update(LC_MONETARY, old_locinfo,
|
|
|
|
lcid[LC_MONETARY], cp[LC_MONETARY])) {
|
|
|
|
copy_threadlocinfo_category(locinfo, old_locinfo, LC_MONETARY);
|
2020-11-18 17:26:10 +01:00
|
|
|
locinfo->lconv_mon_refcount = old_locinfo->lconv_mon_refcount;
|
|
|
|
if(locinfo->lconv_mon_refcount)
|
2022-02-03 11:50:30 +01:00
|
|
|
InterlockedIncrement((LONG *)locinfo->lconv_mon_refcount);
|
2020-11-18 17:26:10 +01:00
|
|
|
if(locinfo->lconv != &cloc_lconv && locinfo->lconv != old_locinfo->lconv) {
|
|
|
|
locinfo->lconv->int_curr_symbol = old_locinfo->lconv->int_curr_symbol;
|
|
|
|
locinfo->lconv->currency_symbol = old_locinfo->lconv->currency_symbol;
|
|
|
|
locinfo->lconv->mon_decimal_point = old_locinfo->lconv->mon_decimal_point;
|
|
|
|
locinfo->lconv->mon_thousands_sep = old_locinfo->lconv->mon_thousands_sep;
|
|
|
|
locinfo->lconv->mon_grouping = old_locinfo->lconv->mon_grouping;
|
|
|
|
locinfo->lconv->positive_sign = old_locinfo->lconv->positive_sign;
|
|
|
|
locinfo->lconv->negative_sign = old_locinfo->lconv->negative_sign;
|
|
|
|
locinfo->lconv->int_frac_digits = old_locinfo->lconv->int_frac_digits;
|
|
|
|
locinfo->lconv->frac_digits = old_locinfo->lconv->frac_digits;
|
|
|
|
locinfo->lconv->p_cs_precedes = old_locinfo->lconv->p_cs_precedes;
|
|
|
|
locinfo->lconv->p_sep_by_space = old_locinfo->lconv->p_sep_by_space;
|
|
|
|
locinfo->lconv->n_cs_precedes = old_locinfo->lconv->n_cs_precedes;
|
|
|
|
locinfo->lconv->n_sep_by_space = old_locinfo->lconv->n_sep_by_space;
|
|
|
|
locinfo->lconv->p_sign_posn = old_locinfo->lconv->p_sign_posn;
|
|
|
|
locinfo->lconv->n_sign_posn = old_locinfo->lconv->n_sign_posn;
|
|
|
|
#if _MSVCR_VER >= 100
|
|
|
|
locinfo->lconv->_W_int_curr_symbol = old_locinfo->lconv->_W_int_curr_symbol;
|
|
|
|
locinfo->lconv->_W_currency_symbol = old_locinfo->lconv->_W_currency_symbol;
|
|
|
|
locinfo->lconv->_W_mon_decimal_point = old_locinfo->lconv->_W_mon_decimal_point;
|
|
|
|
locinfo->lconv->_W_mon_thousands_sep = old_locinfo->lconv->_W_mon_thousands_sep;
|
|
|
|
locinfo->lconv->_W_positive_sign = old_locinfo->lconv->_W_positive_sign;
|
|
|
|
locinfo->lconv->_W_negative_sign = old_locinfo->lconv->_W_negative_sign;
|
|
|
|
#endif
|
|
|
|
}
|
2020-11-30 14:37:48 +01:00
|
|
|
} else if(lcid[LC_MONETARY]) {
|
|
|
|
if(!update_threadlocinfo_category(lcid[LC_MONETARY],
|
|
|
|
cp[LC_MONETARY], locinfo, LC_MONETARY)) {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-12-01 13:51:32 +01:00
|
|
|
locinfo->lconv_mon_refcount = malloc(sizeof(int));
|
2020-11-18 17:26:10 +01:00
|
|
|
if(!locinfo->lconv_mon_refcount) {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-09-24 16:15:54 +02:00
|
|
|
*locinfo->lconv_mon_refcount = 1;
|
2010-04-08 10:24:25 +02:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoA(lcid[LC_MONETARY], LOCALE_SINTLSYMBOL
|
2010-05-09 23:38:11 +02:00
|
|
|
|LOCALE_NOUSEROVERRIDE, buf, 256);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->int_curr_symbol = malloc(i)))
|
2015-09-24 16:15:54 +02:00
|
|
|
memcpy(locinfo->lconv->int_curr_symbol, buf, i);
|
2010-04-08 10:24:25 +02:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoA(lcid[LC_MONETARY], LOCALE_SCURRENCY
|
2010-05-09 23:38:11 +02:00
|
|
|
|LOCALE_NOUSEROVERRIDE, buf, 256);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->currency_symbol = malloc(i)))
|
2015-09-24 16:15:54 +02:00
|
|
|
memcpy(locinfo->lconv->currency_symbol, buf, i);
|
2010-04-08 10:24:25 +02:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoA(lcid[LC_MONETARY], LOCALE_SMONDECIMALSEP
|
2010-05-09 23:38:11 +02:00
|
|
|
|LOCALE_NOUSEROVERRIDE, buf, 256);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->mon_decimal_point = malloc(i)))
|
2015-09-24 16:15:54 +02:00
|
|
|
memcpy(locinfo->lconv->mon_decimal_point, buf, i);
|
2010-04-08 10:24:25 +02:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoA(lcid[LC_MONETARY], LOCALE_SMONTHOUSANDSEP
|
2010-05-09 23:38:11 +02:00
|
|
|
|LOCALE_NOUSEROVERRIDE, buf, 256);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->mon_thousands_sep = malloc(i)))
|
2015-09-24 16:15:54 +02:00
|
|
|
memcpy(locinfo->lconv->mon_thousands_sep, buf, i);
|
2010-04-08 10:24:25 +02:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoA(lcid[LC_MONETARY], LOCALE_SMONGROUPING
|
2010-05-09 23:38:11 +02:00
|
|
|
|LOCALE_NOUSEROVERRIDE, buf, 256);
|
2010-04-08 10:24:25 +02:00
|
|
|
if(i>1)
|
|
|
|
i = i/2 + (buf[i-2]=='0'?0:1);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->mon_grouping = malloc(i))) {
|
2010-04-08 10:24:25 +02:00
|
|
|
for(i=0; buf[i+1]==';'; i+=2)
|
2015-09-24 16:15:54 +02:00
|
|
|
locinfo->lconv->mon_grouping[i/2] = buf[i]-'0';
|
|
|
|
locinfo->lconv->mon_grouping[i/2] = buf[i]-'0';
|
2010-04-08 10:24:25 +02:00
|
|
|
if(buf[i] != '0')
|
2015-09-24 16:15:54 +02:00
|
|
|
locinfo->lconv->mon_grouping[i/2+1] = 127;
|
2010-04-08 10:24:25 +02:00
|
|
|
} else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoA(lcid[LC_MONETARY], LOCALE_SPOSITIVESIGN
|
2010-05-09 23:38:11 +02:00
|
|
|
|LOCALE_NOUSEROVERRIDE, buf, 256);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->positive_sign = malloc(i)))
|
2015-09-24 16:15:54 +02:00
|
|
|
memcpy(locinfo->lconv->positive_sign, buf, i);
|
2010-04-08 10:24:25 +02:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoA(lcid[LC_MONETARY], LOCALE_SNEGATIVESIGN
|
2010-05-09 23:38:11 +02:00
|
|
|
|LOCALE_NOUSEROVERRIDE, buf, 256);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->negative_sign = malloc(i)))
|
2015-09-24 16:15:54 +02:00
|
|
|
memcpy(locinfo->lconv->negative_sign, buf, i);
|
2010-04-08 10:24:25 +02:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(GetLocaleInfoW(lcid[LC_MONETARY], LOCALE_IINTLCURRDIGITS
|
2020-11-18 16:04:09 +01:00
|
|
|
|LOCALE_NOUSEROVERRIDE|LOCALE_RETURN_NUMBER, (WCHAR *)&val, 2))
|
|
|
|
locinfo->lconv->int_frac_digits = val;
|
2010-04-08 10:24:25 +02:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(GetLocaleInfoW(lcid[LC_MONETARY], LOCALE_ICURRDIGITS
|
2020-11-18 16:04:09 +01:00
|
|
|
|LOCALE_NOUSEROVERRIDE|LOCALE_RETURN_NUMBER, (WCHAR *)&val, 2))
|
|
|
|
locinfo->lconv->frac_digits = val;
|
2010-04-08 10:24:25 +02:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(GetLocaleInfoW(lcid[LC_MONETARY], LOCALE_IPOSSYMPRECEDES
|
2020-11-18 16:04:09 +01:00
|
|
|
|LOCALE_NOUSEROVERRIDE|LOCALE_RETURN_NUMBER, (WCHAR *)&val, 2))
|
|
|
|
locinfo->lconv->p_cs_precedes = val;
|
2010-04-08 10:24:25 +02:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(GetLocaleInfoW(lcid[LC_MONETARY], LOCALE_IPOSSEPBYSPACE
|
2020-11-18 16:04:09 +01:00
|
|
|
|LOCALE_NOUSEROVERRIDE|LOCALE_RETURN_NUMBER, (WCHAR *)&val, 2))
|
|
|
|
locinfo->lconv->p_sep_by_space = val;
|
2010-04-08 10:24:25 +02:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(GetLocaleInfoW(lcid[LC_MONETARY], LOCALE_INEGSYMPRECEDES
|
2020-11-18 16:04:09 +01:00
|
|
|
|LOCALE_NOUSEROVERRIDE|LOCALE_RETURN_NUMBER, (WCHAR *)&val, 2))
|
|
|
|
locinfo->lconv->n_cs_precedes = val;
|
2010-04-08 10:24:25 +02:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(GetLocaleInfoW(lcid[LC_MONETARY], LOCALE_INEGSEPBYSPACE
|
2020-11-18 16:04:09 +01:00
|
|
|
|LOCALE_NOUSEROVERRIDE|LOCALE_RETURN_NUMBER, (WCHAR *)&val, 2))
|
|
|
|
locinfo->lconv->n_sep_by_space = val;
|
2010-04-08 10:24:25 +02:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(GetLocaleInfoW(lcid[LC_MONETARY], LOCALE_IPOSSIGNPOSN
|
2020-11-18 16:04:09 +01:00
|
|
|
|LOCALE_NOUSEROVERRIDE|LOCALE_RETURN_NUMBER, (WCHAR *)&val, 2))
|
|
|
|
locinfo->lconv->p_sign_posn = val;
|
2010-04-08 10:24:25 +02:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(GetLocaleInfoW(lcid[LC_MONETARY], LOCALE_INEGSIGNPOSN
|
2020-11-18 16:04:09 +01:00
|
|
|
|LOCALE_NOUSEROVERRIDE|LOCALE_RETURN_NUMBER, (WCHAR *)&val, 2))
|
|
|
|
locinfo->lconv->n_sign_posn = val;
|
2010-04-08 10:24:25 +02:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2014-11-21 20:36:46 +01:00
|
|
|
|
2016-05-04 14:29:50 +02:00
|
|
|
#if _MSVCR_VER >= 100
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoW(lcid[LC_MONETARY], LOCALE_SINTLSYMBOL
|
2014-11-21 20:36:46 +01:00
|
|
|
|LOCALE_NOUSEROVERRIDE, wbuf, 256);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->_W_int_curr_symbol = malloc(i * sizeof(wchar_t))))
|
2020-11-27 14:16:49 +01:00
|
|
|
memcpy(locinfo->lconv->_W_int_curr_symbol, wbuf, i * sizeof(wchar_t));
|
2014-11-21 20:36:46 +01:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2014-11-21 20:36:46 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoW(lcid[LC_MONETARY], LOCALE_SCURRENCY
|
2014-11-21 20:36:46 +01:00
|
|
|
|LOCALE_NOUSEROVERRIDE, wbuf, 256);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->_W_currency_symbol = malloc(i * sizeof(wchar_t))))
|
2020-11-27 14:16:49 +01:00
|
|
|
memcpy(locinfo->lconv->_W_currency_symbol, wbuf, i * sizeof(wchar_t));
|
2014-11-21 20:36:46 +01:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2014-11-21 20:36:46 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoW(lcid[LC_MONETARY], LOCALE_SMONDECIMALSEP
|
2014-11-21 20:36:46 +01:00
|
|
|
|LOCALE_NOUSEROVERRIDE, wbuf, 256);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->_W_mon_decimal_point = malloc(i * sizeof(wchar_t))))
|
2020-11-27 14:16:49 +01:00
|
|
|
memcpy(locinfo->lconv->_W_mon_decimal_point, wbuf, i * sizeof(wchar_t));
|
2014-11-21 20:36:46 +01:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2014-11-21 20:36:46 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoW(lcid[LC_MONETARY], LOCALE_SMONTHOUSANDSEP
|
2014-11-21 20:36:46 +01:00
|
|
|
|LOCALE_NOUSEROVERRIDE, wbuf, 256);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->_W_mon_thousands_sep = malloc(i * sizeof(wchar_t))))
|
2020-11-27 14:16:49 +01:00
|
|
|
memcpy(locinfo->lconv->_W_mon_thousands_sep, wbuf, i * sizeof(wchar_t));
|
2014-11-21 20:36:46 +01:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2014-11-21 20:36:46 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoW(lcid[LC_MONETARY], LOCALE_SPOSITIVESIGN
|
2014-11-21 20:36:46 +01:00
|
|
|
|LOCALE_NOUSEROVERRIDE, wbuf, 256);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->_W_positive_sign = malloc(i * sizeof(wchar_t))))
|
2020-11-27 14:16:49 +01:00
|
|
|
memcpy(locinfo->lconv->_W_positive_sign, wbuf, i * sizeof(wchar_t));
|
2014-11-21 20:36:46 +01:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2014-11-21 20:36:46 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoW(lcid[LC_MONETARY], LOCALE_SNEGATIVESIGN
|
2014-11-21 20:36:46 +01:00
|
|
|
|LOCALE_NOUSEROVERRIDE, wbuf, 256);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->_W_negative_sign = malloc(i * sizeof(wchar_t))))
|
2020-11-27 14:16:49 +01:00
|
|
|
memcpy(locinfo->lconv->_W_negative_sign, wbuf, i * sizeof(wchar_t));
|
2014-11-21 20:36:46 +01:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2014-11-21 20:36:46 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
2010-04-08 10:24:25 +02:00
|
|
|
} else {
|
2020-11-18 17:26:10 +01:00
|
|
|
if (locinfo->lconv != &cloc_lconv) {
|
|
|
|
locinfo->lconv->int_curr_symbol = cloc_lconv.int_curr_symbol;
|
|
|
|
locinfo->lconv->currency_symbol = cloc_lconv.currency_symbol;
|
|
|
|
locinfo->lconv->mon_decimal_point = cloc_lconv.mon_decimal_point;
|
|
|
|
locinfo->lconv->mon_thousands_sep = cloc_lconv.mon_thousands_sep;
|
|
|
|
locinfo->lconv->mon_grouping = cloc_lconv.mon_grouping;
|
|
|
|
locinfo->lconv->positive_sign = cloc_lconv.positive_sign;
|
|
|
|
locinfo->lconv->negative_sign = cloc_lconv.negative_sign;
|
|
|
|
locinfo->lconv->int_frac_digits = cloc_lconv.int_frac_digits;
|
|
|
|
locinfo->lconv->frac_digits = cloc_lconv.frac_digits;
|
|
|
|
locinfo->lconv->p_cs_precedes = cloc_lconv.p_cs_precedes;
|
|
|
|
locinfo->lconv->p_sep_by_space = cloc_lconv.p_sep_by_space;
|
|
|
|
locinfo->lconv->n_cs_precedes = cloc_lconv.n_cs_precedes;
|
|
|
|
locinfo->lconv->n_sep_by_space = cloc_lconv.n_sep_by_space;
|
|
|
|
locinfo->lconv->p_sign_posn = cloc_lconv.p_sign_posn;
|
|
|
|
locinfo->lconv->n_sign_posn = cloc_lconv.n_sign_posn;
|
2010-04-15 14:24:53 +02:00
|
|
|
|
2016-05-04 14:29:50 +02:00
|
|
|
#if _MSVCR_VER >= 100
|
2020-11-18 17:26:10 +01:00
|
|
|
locinfo->lconv->_W_int_curr_symbol = cloc_lconv._W_int_curr_symbol;
|
|
|
|
locinfo->lconv->_W_currency_symbol = cloc_lconv._W_currency_symbol;
|
|
|
|
locinfo->lconv->_W_mon_decimal_point = cloc_lconv._W_mon_decimal_point;
|
|
|
|
locinfo->lconv->_W_mon_thousands_sep = cloc_lconv._W_mon_thousands_sep;
|
|
|
|
locinfo->lconv->_W_positive_sign = cloc_lconv._W_positive_sign;
|
|
|
|
locinfo->lconv->_W_negative_sign = cloc_lconv._W_negative_sign;
|
2014-11-21 20:36:46 +01:00
|
|
|
#endif
|
2020-11-18 17:26:10 +01:00
|
|
|
}
|
2014-11-21 20:36:46 +01:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!init_category_name("C", 1, locinfo, LC_MONETARY)) {
|
2020-11-18 17:25:39 +01:00
|
|
|
free_locinfo(locinfo);
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-04-08 10:24:25 +02:00
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(locale_name[LC_NUMERIC] &&
|
|
|
|
!init_category_name(locale_name[LC_NUMERIC],
|
|
|
|
locale_len[LC_NUMERIC], locinfo, LC_NUMERIC)) {
|
2018-05-09 17:36:17 +02:00
|
|
|
free_locinfo(locinfo);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!category_needs_update(LC_NUMERIC, old_locinfo,
|
|
|
|
lcid[LC_NUMERIC], cp[LC_NUMERIC])) {
|
|
|
|
copy_threadlocinfo_category(locinfo, old_locinfo, LC_NUMERIC);
|
2020-11-18 17:26:10 +01:00
|
|
|
locinfo->lconv_num_refcount = old_locinfo->lconv_num_refcount;
|
|
|
|
if(locinfo->lconv_num_refcount)
|
2022-02-03 11:50:30 +01:00
|
|
|
InterlockedIncrement((LONG *)locinfo->lconv_num_refcount);
|
2020-11-18 17:26:10 +01:00
|
|
|
if(locinfo->lconv != &cloc_lconv && locinfo->lconv != old_locinfo->lconv) {
|
|
|
|
locinfo->lconv->decimal_point = old_locinfo->lconv->decimal_point;
|
|
|
|
locinfo->lconv->thousands_sep = old_locinfo->lconv->thousands_sep;
|
|
|
|
locinfo->lconv->grouping = old_locinfo->lconv->grouping;
|
|
|
|
#if _MSVCR_VER >= 100
|
|
|
|
locinfo->lconv->_W_decimal_point = old_locinfo->lconv->_W_decimal_point;
|
|
|
|
locinfo->lconv->_W_thousands_sep = old_locinfo->lconv->_W_thousands_sep;
|
|
|
|
#endif
|
|
|
|
}
|
2020-11-30 14:37:48 +01:00
|
|
|
} else if(lcid[LC_NUMERIC]) {
|
|
|
|
if(!update_threadlocinfo_category(lcid[LC_NUMERIC],
|
|
|
|
cp[LC_NUMERIC], locinfo, LC_NUMERIC)) {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-12-01 13:51:32 +01:00
|
|
|
locinfo->lconv_num_refcount = malloc(sizeof(int));
|
2020-11-18 17:26:10 +01:00
|
|
|
if(!locinfo->lconv_num_refcount) {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-09-24 16:15:54 +02:00
|
|
|
*locinfo->lconv_num_refcount = 1;
|
2010-04-08 10:24:25 +02:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoA(lcid[LC_NUMERIC], LOCALE_SDECIMAL
|
2010-05-09 23:38:11 +02:00
|
|
|
|LOCALE_NOUSEROVERRIDE, buf, 256);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->decimal_point = malloc(i)))
|
2015-09-24 16:15:54 +02:00
|
|
|
memcpy(locinfo->lconv->decimal_point, buf, i);
|
2010-04-08 10:24:25 +02:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoA(lcid[LC_NUMERIC], LOCALE_STHOUSAND
|
2010-05-09 23:38:11 +02:00
|
|
|
|LOCALE_NOUSEROVERRIDE, buf, 256);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->thousands_sep = malloc(i)))
|
2015-09-24 16:15:54 +02:00
|
|
|
memcpy(locinfo->lconv->thousands_sep, buf, i);
|
2010-04-08 10:24:25 +02:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoA(lcid[LC_NUMERIC], LOCALE_SGROUPING
|
2010-05-09 23:38:11 +02:00
|
|
|
|LOCALE_NOUSEROVERRIDE, buf, 256);
|
2010-04-08 10:24:25 +02:00
|
|
|
if(i>1)
|
|
|
|
i = i/2 + (buf[i-2]=='0'?0:1);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->grouping = malloc(i))) {
|
2010-04-08 10:24:25 +02:00
|
|
|
for(i=0; buf[i+1]==';'; i+=2)
|
2015-09-24 16:15:54 +02:00
|
|
|
locinfo->lconv->grouping[i/2] = buf[i]-'0';
|
|
|
|
locinfo->lconv->grouping[i/2] = buf[i]-'0';
|
2010-04-08 10:24:25 +02:00
|
|
|
if(buf[i] != '0')
|
2015-09-24 16:15:54 +02:00
|
|
|
locinfo->lconv->grouping[i/2+1] = 127;
|
2010-04-08 10:24:25 +02:00
|
|
|
} else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2010-04-08 10:24:25 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2014-11-21 20:36:46 +01:00
|
|
|
|
2016-05-04 14:29:50 +02:00
|
|
|
#if _MSVCR_VER >= 100
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoW(lcid[LC_NUMERIC], LOCALE_SDECIMAL
|
2014-11-21 20:36:46 +01:00
|
|
|
|LOCALE_NOUSEROVERRIDE, wbuf, 256);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->_W_decimal_point = malloc(i * sizeof(wchar_t))))
|
2020-11-27 14:16:49 +01:00
|
|
|
memcpy(locinfo->lconv->_W_decimal_point, wbuf, i * sizeof(wchar_t));
|
2014-11-21 20:36:46 +01:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2014-11-21 20:36:46 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
i = GetLocaleInfoW(lcid[LC_NUMERIC], LOCALE_STHOUSAND
|
2014-11-21 20:36:46 +01:00
|
|
|
|LOCALE_NOUSEROVERRIDE, wbuf, 256);
|
2020-12-01 13:51:32 +01:00
|
|
|
if(i && (locinfo->lconv->_W_thousands_sep = malloc(i * sizeof(wchar_t))))
|
2020-11-27 14:16:49 +01:00
|
|
|
memcpy(locinfo->lconv->_W_thousands_sep, wbuf, i * sizeof(wchar_t));
|
2014-11-21 20:36:46 +01:00
|
|
|
else {
|
2015-09-24 16:15:54 +02:00
|
|
|
free_locinfo(locinfo);
|
2014-11-21 20:36:46 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
2010-04-08 10:24:25 +02:00
|
|
|
} else {
|
2020-11-18 17:26:10 +01:00
|
|
|
if (locinfo->lconv != &cloc_lconv) {
|
|
|
|
locinfo->lconv->decimal_point = cloc_lconv.decimal_point;
|
|
|
|
locinfo->lconv->thousands_sep = cloc_lconv.thousands_sep;
|
|
|
|
locinfo->lconv->grouping = cloc_lconv.grouping;
|
2010-04-15 14:24:53 +02:00
|
|
|
|
2016-05-04 14:29:50 +02:00
|
|
|
#if _MSVCR_VER >= 100
|
2020-11-18 17:26:10 +01:00
|
|
|
locinfo->lconv->_W_decimal_point = cloc_lconv._W_decimal_point;
|
|
|
|
locinfo->lconv->_W_thousands_sep = cloc_lconv._W_thousands_sep;
|
2014-11-21 20:36:46 +01:00
|
|
|
#endif
|
2020-11-18 17:26:10 +01:00
|
|
|
}
|
2014-11-21 20:36:46 +01:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if (!init_category_name("C", 1, locinfo, LC_NUMERIC)) {
|
2020-11-18 17:25:39 +01:00
|
|
|
free_locinfo(locinfo);
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-04-08 10:24:25 +02:00
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(locale_name[LC_TIME] &&
|
|
|
|
!init_category_name(locale_name[LC_TIME],
|
|
|
|
locale_len[LC_TIME], locinfo, LC_TIME)) {
|
2018-05-09 17:36:17 +02:00
|
|
|
free_locinfo(locinfo);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!category_needs_update(LC_TIME, old_locinfo,
|
|
|
|
lcid[LC_TIME], cp[LC_TIME])) {
|
|
|
|
copy_threadlocinfo_category(locinfo, old_locinfo, LC_TIME);
|
2020-11-18 17:26:15 +01:00
|
|
|
locinfo->lc_time_curr = old_locinfo->lc_time_curr;
|
2020-11-25 20:24:09 +01:00
|
|
|
InterlockedIncrement(&locinfo->lc_time_curr->refcount);
|
2020-11-30 14:37:48 +01:00
|
|
|
} else if(lcid[LC_TIME]) {
|
|
|
|
if(!update_threadlocinfo_category(lcid[LC_TIME],
|
|
|
|
cp[LC_TIME], locinfo, LC_TIME)) {
|
2019-12-04 16:22:14 +01:00
|
|
|
free_locinfo(locinfo);
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-12-07 13:48:22 +01:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
locinfo->lc_time_curr = create_time_data(lcid[LC_TIME]);
|
2015-09-24 16:16:16 +02:00
|
|
|
if(!locinfo->lc_time_curr) {
|
|
|
|
free_locinfo(locinfo);
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-12-04 16:22:14 +01:00
|
|
|
} else {
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!init_category_name("C", 1, locinfo, LC_TIME)) {
|
2020-11-18 17:25:39 +01:00
|
|
|
free_locinfo(locinfo);
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-12-04 16:22:14 +01:00
|
|
|
locinfo->lc_time_curr = &cloc_time_data;
|
2020-11-25 20:24:09 +01:00
|
|
|
InterlockedIncrement(&locinfo->lc_time_curr->refcount);
|
2011-12-07 13:48:22 +01:00
|
|
|
}
|
|
|
|
|
2015-09-24 16:15:54 +02:00
|
|
|
return locinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _create_locale (MSVCRT.@)
|
|
|
|
*/
|
2020-11-26 19:19:24 +01:00
|
|
|
_locale_t CDECL _create_locale(int category, const char *locale)
|
2015-09-24 16:15:54 +02:00
|
|
|
{
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t loc;
|
2015-09-24 16:15:54 +02:00
|
|
|
|
2020-12-01 13:51:32 +01:00
|
|
|
loc = malloc(sizeof(_locale_tstruct));
|
2015-09-24 16:15:54 +02:00
|
|
|
if(!loc)
|
|
|
|
return NULL;
|
|
|
|
|
2015-09-24 16:16:16 +02:00
|
|
|
loc->locinfo = create_locinfo(category, locale, NULL);
|
2015-09-24 16:15:54 +02:00
|
|
|
if(!loc->locinfo) {
|
2020-12-01 13:51:32 +01:00
|
|
|
free(loc);
|
2015-09-24 16:15:54 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
loc->mbcinfo = create_mbcinfo(loc->locinfo->lc_id[LC_CTYPE].wCodePage,
|
|
|
|
loc->locinfo->lc_handle[LC_CTYPE], NULL);
|
2015-09-24 16:15:54 +02:00
|
|
|
if(!loc->mbcinfo) {
|
|
|
|
free_locinfo(loc->locinfo);
|
2020-12-01 13:51:32 +01:00
|
|
|
free(loc);
|
2015-09-24 16:15:54 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2010-04-08 10:24:25 +02:00
|
|
|
return loc;
|
|
|
|
}
|
2010-04-15 14:25:13 +02:00
|
|
|
|
2018-01-10 07:21:44 +01:00
|
|
|
#if _MSVCR_VER >= 110
|
2016-08-17 13:17:17 +02:00
|
|
|
/*********************************************************************
|
2018-01-10 07:21:44 +01:00
|
|
|
* _wcreate_locale (MSVCR110.@)
|
2016-08-17 13:17:17 +02:00
|
|
|
*/
|
2020-12-02 00:53:47 +01:00
|
|
|
_locale_t CDECL _wcreate_locale(int category, const wchar_t *locale)
|
2016-08-17 13:17:17 +02:00
|
|
|
{
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t loc;
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t len;
|
2016-08-17 13:17:17 +02:00
|
|
|
char *str;
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(category<LC_MIN || category>LC_MAX || !locale)
|
2016-08-17 13:17:17 +02:00
|
|
|
return NULL;
|
|
|
|
|
2020-12-03 19:10:54 +01:00
|
|
|
len = wcstombs(NULL, locale, 0);
|
2016-08-17 13:17:17 +02:00
|
|
|
if(len == -1)
|
|
|
|
return NULL;
|
2020-12-01 13:51:32 +01:00
|
|
|
if(!(str = malloc(++len)))
|
2016-08-17 13:17:17 +02:00
|
|
|
return NULL;
|
2020-12-03 19:10:54 +01:00
|
|
|
wcstombs(str, locale, len);
|
2016-08-17 13:17:17 +02:00
|
|
|
|
2020-11-26 19:19:24 +01:00
|
|
|
loc = _create_locale(category, str);
|
2016-08-17 13:17:17 +02:00
|
|
|
|
2020-12-01 13:51:32 +01:00
|
|
|
free(str);
|
2016-08-17 13:17:17 +02:00
|
|
|
return loc;
|
|
|
|
}
|
2018-01-10 07:21:44 +01:00
|
|
|
#endif
|
2016-08-17 13:17:17 +02:00
|
|
|
|
2010-04-15 14:25:13 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* setlocale (MSVCRT.@)
|
|
|
|
*/
|
2020-12-02 00:53:47 +01:00
|
|
|
char* CDECL setlocale(int category, const char* locale)
|
2010-04-15 14:25:13 +02:00
|
|
|
{
|
2020-11-25 20:24:41 +01:00
|
|
|
thread_data_t *data = msvcrt_get_thread_data();
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo locinfo = get_locinfo(), newlocinfo;
|
2010-04-15 14:25:13 +02:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(category<LC_MIN || category>LC_MAX)
|
2010-04-19 10:58:51 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if(!locale) {
|
2020-11-30 14:37:48 +01:00
|
|
|
if(category == LC_ALL)
|
2011-05-24 17:22:42 +02:00
|
|
|
return construct_lc_all(locinfo);
|
2010-04-15 14:25:13 +02:00
|
|
|
|
2011-05-24 17:22:42 +02:00
|
|
|
return locinfo->lc_category[category].locale;
|
2010-04-15 14:25:13 +02:00
|
|
|
}
|
|
|
|
|
2015-09-24 16:16:16 +02:00
|
|
|
newlocinfo = create_locinfo(category, locale, locinfo);
|
2015-09-24 16:16:02 +02:00
|
|
|
if(!newlocinfo) {
|
2010-04-19 10:58:51 +02:00
|
|
|
WARN("%d %s failed\n", category, locale);
|
2010-04-15 14:25:13 +02:00
|
|
|
return NULL;
|
2010-04-19 10:58:51 +02:00
|
|
|
}
|
2010-04-15 14:25:13 +02:00
|
|
|
|
2019-01-23 11:59:05 +01:00
|
|
|
if(locale[0] != 'C' || locale[1] != '\0')
|
|
|
|
initial_locale = FALSE;
|
|
|
|
|
2020-11-25 20:24:41 +01:00
|
|
|
if(data->locale_flags & LOCALE_THREAD)
|
|
|
|
{
|
|
|
|
if(data->locale_flags & LOCALE_FREE)
|
|
|
|
free_locinfo(data->locinfo);
|
|
|
|
data->locinfo = newlocinfo;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-26 11:40:04 +02:00
|
|
|
int i;
|
|
|
|
|
2020-11-25 20:24:41 +01:00
|
|
|
_lock_locales();
|
|
|
|
free_locinfo(MSVCRT_locale->locinfo);
|
|
|
|
MSVCRT_locale->locinfo = newlocinfo;
|
|
|
|
|
2020-11-18 17:26:24 +01:00
|
|
|
MSVCRT___lc_codepage = newlocinfo->lc_codepage;
|
|
|
|
MSVCRT___lc_collate_cp = newlocinfo->lc_collate_cp;
|
|
|
|
MSVCRT___mb_cur_max = newlocinfo->mb_cur_max;
|
|
|
|
MSVCRT__pctype = newlocinfo->pctype;
|
2020-11-30 14:37:48 +01:00
|
|
|
for(i=LC_MIN; i<=LC_MAX; i++)
|
2011-05-26 11:40:04 +02:00
|
|
|
MSVCRT___lc_handle[i] = MSVCRT_locale->locinfo->lc_handle[i];
|
2020-11-25 20:24:41 +01:00
|
|
|
_unlock_locales();
|
|
|
|
update_thread_locale(data);
|
2010-04-15 14:26:33 +02:00
|
|
|
}
|
2010-04-15 14:25:13 +02:00
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(category == LC_ALL)
|
2020-11-25 20:24:41 +01:00
|
|
|
return construct_lc_all(data->locinfo);
|
2010-04-15 14:25:13 +02:00
|
|
|
|
2020-11-25 20:24:41 +01:00
|
|
|
return data->locinfo->lc_category[category].locale;
|
2010-04-15 14:25:13 +02:00
|
|
|
}
|
2011-05-24 17:22:23 +02:00
|
|
|
|
2013-08-29 12:07:03 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _wsetlocale (MSVCRT.@)
|
|
|
|
*/
|
2020-12-02 00:53:47 +01:00
|
|
|
wchar_t* CDECL _wsetlocale(int category, const wchar_t* wlocale)
|
2013-08-29 12:07:03 +02:00
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
static wchar_t current_lc_all[MAX_LOCALE_LENGTH];
|
2013-08-29 12:07:03 +02:00
|
|
|
|
|
|
|
char *locale = NULL;
|
|
|
|
const char *ret;
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t len;
|
2013-08-29 12:07:03 +02:00
|
|
|
|
|
|
|
if(wlocale) {
|
2020-12-03 19:10:54 +01:00
|
|
|
len = wcstombs(NULL, wlocale, 0);
|
2013-08-29 12:07:03 +02:00
|
|
|
if(len == -1)
|
|
|
|
return NULL;
|
|
|
|
|
2020-12-01 13:51:32 +01:00
|
|
|
locale = malloc(++len);
|
2013-08-29 12:07:03 +02:00
|
|
|
if(!locale)
|
|
|
|
return NULL;
|
|
|
|
|
2020-12-03 19:10:54 +01:00
|
|
|
wcstombs(locale, wlocale, len);
|
2013-08-29 12:07:03 +02:00
|
|
|
}
|
|
|
|
|
2016-06-16 16:44:41 +02:00
|
|
|
_lock_locales();
|
2020-12-02 00:53:47 +01:00
|
|
|
ret = setlocale(category, locale);
|
2020-12-01 13:51:32 +01:00
|
|
|
free(locale);
|
2013-08-29 12:07:03 +02:00
|
|
|
|
2020-12-02 00:53:51 +01:00
|
|
|
if(ret && mbstowcs(current_lc_all, ret, MAX_LOCALE_LENGTH)==-1)
|
2013-08-29 12:07:03 +02:00
|
|
|
ret = NULL;
|
|
|
|
|
2016-06-16 16:44:41 +02:00
|
|
|
_unlock_locales();
|
2013-08-29 12:07:03 +02:00
|
|
|
return ret ? current_lc_all : NULL;
|
|
|
|
}
|
|
|
|
|
2018-01-04 05:33:01 +01:00
|
|
|
#if _MSVCR_VER >= 80
|
2014-04-21 14:32:40 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _configthreadlocale (MSVCR80.@)
|
|
|
|
*/
|
2011-05-24 17:22:23 +02:00
|
|
|
int CDECL _configthreadlocale(int type)
|
|
|
|
{
|
|
|
|
thread_data_t *data = msvcrt_get_thread_data();
|
|
|
|
int ret;
|
|
|
|
|
2020-12-04 15:50:25 +01:00
|
|
|
ret = (data->locale_flags & LOCALE_THREAD ? _ENABLE_PER_THREAD_LOCALE :
|
|
|
|
_DISABLE_PER_THREAD_LOCALE);
|
2011-05-24 17:22:23 +02:00
|
|
|
|
2020-12-04 15:50:25 +01:00
|
|
|
if(type == _ENABLE_PER_THREAD_LOCALE)
|
2020-11-25 20:24:37 +01:00
|
|
|
data->locale_flags |= LOCALE_THREAD;
|
2020-12-04 15:50:25 +01:00
|
|
|
else if(type == _DISABLE_PER_THREAD_LOCALE)
|
2020-11-25 20:24:37 +01:00
|
|
|
data->locale_flags &= ~LOCALE_THREAD;
|
|
|
|
else if(type)
|
|
|
|
ret = -1;
|
2011-05-24 17:22:23 +02:00
|
|
|
|
2020-11-25 20:24:37 +01:00
|
|
|
return ret;
|
2011-05-24 17:22:23 +02:00
|
|
|
}
|
2018-01-04 05:33:01 +01:00
|
|
|
#endif
|
2011-05-26 11:40:04 +02:00
|
|
|
|
|
|
|
BOOL msvcrt_init_locale(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2016-06-16 16:44:41 +02:00
|
|
|
_lock_locales();
|
2020-11-26 19:19:24 +01:00
|
|
|
MSVCRT_locale = _create_locale(0, "C");
|
2016-06-16 16:44:41 +02:00
|
|
|
_unlock_locales();
|
2011-05-26 11:40:04 +02:00
|
|
|
if(!MSVCRT_locale)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
MSVCRT___lc_codepage = MSVCRT_locale->locinfo->lc_codepage;
|
|
|
|
MSVCRT___lc_collate_cp = MSVCRT_locale->locinfo->lc_collate_cp;
|
|
|
|
MSVCRT___mb_cur_max = MSVCRT_locale->locinfo->mb_cur_max;
|
|
|
|
MSVCRT__pctype = MSVCRT_locale->locinfo->pctype;
|
2020-11-30 14:37:48 +01:00
|
|
|
for(i=LC_MIN; i<=LC_MAX; i++)
|
2011-05-26 11:40:04 +02:00
|
|
|
MSVCRT___lc_handle[i] = MSVCRT_locale->locinfo->lc_handle[i];
|
2011-10-12 11:54:53 +02:00
|
|
|
_setmbcp(_MB_CP_ANSI);
|
2011-05-26 11:40:04 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2019-03-21 16:30:21 +01:00
|
|
|
|
|
|
|
#if _MSVCR_VER >= 120
|
|
|
|
/*********************************************************************
|
|
|
|
* wctrans (MSVCR120.@)
|
|
|
|
*/
|
2020-12-02 00:53:47 +01:00
|
|
|
wctrans_t CDECL wctrans(const char *property)
|
2019-03-21 16:30:21 +01:00
|
|
|
{
|
|
|
|
static const char str_tolower[] = "tolower";
|
|
|
|
static const char str_toupper[] = "toupper";
|
|
|
|
|
|
|
|
if(!strcmp(property, str_tolower))
|
|
|
|
return 2;
|
|
|
|
if(!strcmp(property, str_toupper))
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|