ReactOS 0.4.15-dev-8344-g0574987
locale.c File Reference
#include <precomp.h>
#include <locale.h>
#include "mbctype.h"
#include <internal/wine/msvcrt.h>
Include dependency graph for locale.c:

Go to the source code of this file.

Classes

struct  locale_search_t
 

Macros

#define MAX_ELEM_LEN   64 /* Max length of country/language/CP string */
 
#define MAX_LOCALE_LENGTH   256
 
#define LOCK_LOCALE   _mlock(_SETLOCALE_LOCK);
 
#define UNLOCK_LOCALE   _munlock(_SETLOCALE_LOCK);
 
#define MSVCRT_LEADBYTE   0x8000
 
#define MSVCRT_C1_DEFINED   0x200
 
#define FOUND_LANGUAGE   0x4
 
#define FOUND_COUNTRY   0x2
 
#define FOUND_CODEPAGE   0x1
 
#define CONTINUE_LOOKING   TRUE
 
#define STOP_LOOKING   FALSE
 

Functions

static void remap_synonym (char *name)
 
static int compare_info (LCID lcid, DWORD flags, char *buff, const char *cmp, BOOL exact)
 
static BOOL CALLBACK find_best_locale_proc (HMODULE hModule, LPCSTR type, LPCSTR name, WORD LangID, LONG_PTR lParam)
 
int atoi (const char *)
 
LCID MSVCRT_locale_to_LCID (const char *locale, unsigned short *codepage)
 
static BOOL update_threadlocinfo_category (LCID lcid, unsigned short cp, MSVCRT__locale_t loc, int category)
 
static void swap_pointers (void **p1, void **p2)
 
MSVCRT_pthreadlocinfo get_locinfo (void)
 
MSVCRT_pthreadmbcinfo get_mbcinfo (void)
 
static charconstruct_lc_all (MSVCRT_pthreadlocinfo locinfo)
 
wchar_t *CDECL _wsetlocale (int category, const wchar_t *locale)
 
char *CDECL _Getdays (void)
 
char *CDECL _Getmonths (void)
 
void *CDECL _Gettnames (void)
 
int CDECL __crtLCMapStringA (LCID lcid, DWORD mapflags, const char *src, int srclen, char *dst, int dstlen, unsigned int codepage, int xflag)
 
int CDECL __crtLCMapStringW (LCID lcid, DWORD mapflags, const wchar_t *src, int srclen, wchar_t *dst, int dstlen, unsigned int codepage, int xflag)
 
int CDECL __crtCompareStringA (LCID lcid, DWORD flags, const char *src1, int len1, const char *src2, int len2)
 
int CDECL __crtCompareStringW (LCID lcid, DWORD flags, const wchar_t *src1, int len1, const wchar_t *src2, int len2)
 
int CDECL __crtGetLocaleInfoW (LCID lcid, LCTYPE type, wchar_t *buffer, int len)
 
wint_t CDECL MSVCRT_btowc (int c)
 
BOOL CDECL __crtGetStringTypeW (DWORD unk, DWORD type, wchar_t *buffer, int len, WORD *out)
 
struct lconv *CDECL localeconv (void)
 
int CDECL __lconv_init (void)
 
LCID *CDECL ___lc_handle_func (void)
 
unsigned int CDECL ___lc_codepage_func (void)
 
unsigned int CDECL ___lc_collate_cp_func (void)
 
void free_locinfo (MSVCRT_pthreadlocinfo locinfo)
 
void free_mbcinfo (MSVCRT_pthreadmbcinfo mbcinfo)
 
MSVCRT__locale_t CDECL MSVCRT__get_current_locale (void)
 
void CDECL MSVCRT__free_locale (MSVCRT__locale_t locale)
 
MSVCRT__locale_t CDECL MSVCRT__create_locale (int category, const char *locale)
 
char *CDECL setlocale (int category, const char *locale)
 
int CDECL _configthreadlocale (int type)
 
int CDECL _getmbcp (void)
 
unsigned int CDECL ___setlc_active_func (void)
 
unsigned int *CDECL ___unguarded_readlc_active_add_func (void)
 
void __init_global_locale ()
 
const unsigned short ** __p__pctype (void)
 
const unsigned short *__cdecl __pctype_func (void)
 

Variables

unsigned int __lc_codepage = 0
 
int MSVCRT___lc_collate_cp = 0
 
LCID MSVCRT___lc_handle [LC_MAX - LC_MIN+1] = { 0 }
 
int __mb_cur_max = 1
 
static unsigned char charmax = CHAR_MAX
 
unsigned char _mbctype [257] = { 0 }
 
static const char *const _country_synonyms []
 
unsigned int __setlc_active
 
unsigned int __unguarded_readlc_active
 
MSVCRT__locale_t global_locale = NULL
 

Macro Definition Documentation

◆ CONTINUE_LOOKING

#define CONTINUE_LOOKING   TRUE

Definition at line 116 of file locale.c.

◆ FOUND_CODEPAGE

#define FOUND_CODEPAGE   0x1

Definition at line 105 of file locale.c.

◆ FOUND_COUNTRY

#define FOUND_COUNTRY   0x2

Definition at line 104 of file locale.c.

◆ FOUND_LANGUAGE

#define FOUND_LANGUAGE   0x4

Definition at line 103 of file locale.c.

◆ LOCK_LOCALE

#define LOCK_LOCALE   _mlock(_SETLOCALE_LOCK);

Definition at line 43 of file locale.c.

◆ MAX_ELEM_LEN

#define MAX_ELEM_LEN   64 /* Max length of country/language/CP string */

Definition at line 27 of file locale.c.

◆ MAX_LOCALE_LENGTH

#define MAX_LOCALE_LENGTH   256

Definition at line 28 of file locale.c.

◆ MSVCRT_C1_DEFINED

#define MSVCRT_C1_DEFINED   0x200

Definition at line 47 of file locale.c.

◆ MSVCRT_LEADBYTE

#define MSVCRT_LEADBYTE   0x8000

Definition at line 46 of file locale.c.

◆ STOP_LOOKING

#define STOP_LOOKING   FALSE

Definition at line 117 of file locale.c.

◆ UNLOCK_LOCALE

#define UNLOCK_LOCALE   _munlock(_SETLOCALE_LOCK);

Definition at line 44 of file locale.c.

Function Documentation

◆ ___lc_codepage_func()

unsigned int CDECL ___lc_codepage_func ( void  )

Definition at line 627 of file locale.c.

628{
629 return __lc_codepage;
630}
unsigned int __lc_codepage
Definition: locale.c:34

Referenced by mbrtowc(), START_TEST(), and Test___lc_codepage().

◆ ___lc_collate_cp_func()

unsigned int CDECL ___lc_collate_cp_func ( void  )

Definition at line 635 of file locale.c.

636{
637 return get_locinfo()->lc_collate_cp;
638}
MSVCRT_pthreadlocinfo get_locinfo(void)
Definition: locale.c:354
unsigned int lc_collate_cp
Definition: msvcrt.h:114

Referenced by Test___lc_collate_cp().

◆ ___lc_handle_func()

LCID *CDECL ___lc_handle_func ( void  )

Definition at line 619 of file locale.c.

620{
621 return MSVCRT___lc_handle;
622}
LCID MSVCRT___lc_handle[LC_MAX - LC_MIN+1]
Definition: locale.c:36

Referenced by Test___lc_handle().

◆ ___setlc_active_func()

unsigned int CDECL ___setlc_active_func ( void  )

Definition at line 1481 of file locale.c.

1482{
1483 return __setlc_active;
1484}
unsigned int __setlc_active
Definition: environ.c:16

Referenced by Test___setlc_active().

◆ ___unguarded_readlc_active_add_func()

unsigned int *CDECL ___unguarded_readlc_active_add_func ( void  )

Definition at line 1490 of file locale.c.

1491{
1493}
unsigned int __unguarded_readlc_active
Definition: environ.c:17

Referenced by Test___unguarded_readlc_active().

◆ __crtCompareStringA()

int CDECL __crtCompareStringA ( LCID  lcid,
DWORD  flags,
const char src1,
int  len1,
const char src2,
int  len2 
)

Definition at line 537 of file locale.c.

539{
540 FIXME("(lcid %x, flags %x, %s(%d), %s(%d), partial stub\n",
541 lcid, flags, debugstr_a(src1), len1, debugstr_a(src2), len2 );
542 /* FIXME: probably not entirely right */
543 return CompareStringA( lcid, flags, src1, len1, src2, len2 );
544}
#define FIXME(fmt,...)
Definition: precomp.h:53
INT WINAPI CompareStringA(LCID lcid, DWORD flags, LPCSTR str1, INT len1, LPCSTR str2, INT len2)
Definition: locale.c:4082
GLbitfield flags
Definition: glext.h:7161
#define debugstr_a
Definition: kernel32.h:31

◆ __crtCompareStringW()

int CDECL __crtCompareStringW ( LCID  lcid,
DWORD  flags,
const wchar_t src1,
int  len1,
const wchar_t src2,
int  len2 
)

Definition at line 549 of file locale.c.

551{
552 FIXME("(lcid %x, flags %x, %s(%d), %s(%d), partial stub\n",
553 lcid, flags, debugstr_w(src1), len1, debugstr_w(src2), len2 );
554 /* FIXME: probably not entirely right */
555 return CompareStringW( lcid, flags, src1, len1, src2, len2 );
556}
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: locale.c:4013
#define debugstr_w
Definition: kernel32.h:32

◆ __crtGetLocaleInfoW()

int CDECL __crtGetLocaleInfoW ( LCID  lcid,
LCTYPE  type,
wchar_t buffer,
int  len 
)

Definition at line 561 of file locale.c.

562{
563 FIXME("(lcid %x, type %x, %p(%d), partial stub\n", lcid, type, buffer, len );
564 /* FIXME: probably not entirely right */
565 return GetLocaleInfoW( lcid, type, buffer, len );
566}
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1665
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722

◆ __crtGetStringTypeW()

BOOL CDECL __crtGetStringTypeW ( DWORD  unk,
DWORD  type,
wchar_t buffer,
int  len,
WORD out 
)

Definition at line 589 of file locale.c.

591{
592 FIXME("(unk %x, type %x, wstr %p(%d), %p) partial stub\n",
593 unk, type, buffer, len, out);
594
595 return GetStringTypeW(type, buffer, len, out);
596}
BOOL WINAPI GetStringTypeW(DWORD type, LPCWSTR src, INT count, LPWORD chartype)
Definition: locale.c:3094
static FILE * out
Definition: regtests2xml.c:44

◆ __crtLCMapStringA()

int CDECL __crtLCMapStringA ( LCID  lcid,
DWORD  mapflags,
const char src,
int  srclen,
char dst,
int  dstlen,
unsigned int  codepage,
int  xflag 
)

Definition at line 510 of file locale.c.

513 {
514 FIXME("(lcid %x, flags %x, %s(%d), %p(%d), %x, %d), partial stub!\n",
515 lcid,mapflags,src,srclen,dst,dstlen,codepage,xflag);
516 /* FIXME: A bit incorrect. But msvcrt itself just converts its
517 * arguments to wide strings and then calls LCMapStringW
518 */
519 return LCMapStringA(lcid,mapflags,src,srclen,dst,dstlen);
520}
INT WINAPI LCMapStringA(LCID lcid, DWORD flags, LPCSTR src, INT srclen, LPSTR dst, INT dstlen)
Definition: locale.c:3830
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
static DWORD LPDWORD LPCSTR DWORD srclen
Definition: directory.c:52
static DWORD dstlen
Definition: directory.c:51
int codepage
Definition: win_iconv.c:156

◆ __crtLCMapStringW()

int CDECL __crtLCMapStringW ( LCID  lcid,
DWORD  mapflags,
const wchar_t src,
int  srclen,
wchar_t dst,
int  dstlen,
unsigned int  codepage,
int  xflag 
)

Definition at line 525 of file locale.c.

527{
528 FIXME("(lcid %x, flags %x, %s(%d), %p(%d), %x, %d), partial stub!\n",
529 lcid, mapflags, debugstr_w(src), srclen, dst, dstlen, codepage, xflag);
530
531 return LCMapStringW(lcid, mapflags, src, srclen, dst, dstlen);
532}
INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen, LPWSTR dst, INT dstlen)
Definition: locale.c:3804

◆ __init_global_locale()

void __init_global_locale ( )

Definition at line 1496 of file locale.c.

1497{
1498 unsigned i;
1499
1501 /* Someone created it before us */
1502 if(global_locale)
1503 return;
1505
1506 __lc_codepage = MSVCRT_locale->locinfo->lc_codepage;
1507 MSVCRT___lc_collate_cp = MSVCRT_locale->locinfo->lc_collate_cp;
1508 __mb_cur_max = MSVCRT_locale->locinfo->mb_cur_max;
1509 for(i=LC_MIN; i<=LC_MAX; i++)
1510 MSVCRT___lc_handle[i] = MSVCRT_locale->locinfo->lc_handle[i];
1513}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define LC_MAX
Definition: locale.h:25
#define LC_MIN
Definition: locale.h:24
#define MSVCRT_locale
Definition: locale.h:78
int __cdecl _setmbcp(int)
Definition: _setmbcp.c:218
#define _MB_CP_ANSI
Definition: msvcrt.h:830
int MSVCRT___lc_collate_cp
Definition: locale.c:35
#define LOCK_LOCALE
Definition: locale.c:43
MSVCRT__locale_t global_locale
Definition: locale.c:1495
int __mb_cur_max
Definition: locale.c:37
#define UNLOCK_LOCALE
Definition: locale.c:44
MSVCRT__locale_t CDECL MSVCRT__create_locale(int category, const char *locale)
Definition: locale.c:722

Referenced by __get_MSVCRT_locale().

◆ __lconv_init()

int CDECL __lconv_init ( void  )

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 609 of file locale.c.

610{
611 /* this is used to make chars unsigned */
612 charmax = 255;
613 return 0;
614}
static unsigned char charmax
Definition: locale.c:38

Referenced by my_lconv_init().

◆ __p__pctype()

const unsigned short ** __p__pctype ( void  )

Definition at line 1518 of file locale.c.

1519{
1520 return &get_locinfo()->pctype;
1521}
unsigned short * pctype
Definition: msvcrt.h:131

Referenced by Test__ctype().

◆ __pctype_func()

const unsigned short *__cdecl __pctype_func ( void  )

Definition at line 1523 of file locale.c.

1524{
1525 return get_locinfo()->pctype;
1526}

◆ _configthreadlocale()

int CDECL _configthreadlocale ( int  type)

Definition at line 1424 of file locale.c.

1425{
1428 int ret;
1429
1430 if(!data)
1431 return -1;
1432
1434
1436 if(!data->have_locale) {
1437 /* Copy current global locale */
1439 if(!locale)
1440 return -1;
1441
1442 data->locinfo = locale->locinfo;
1443 data->mbcinfo = locale->mbcinfo;
1444 data->have_locale = TRUE;
1446 }
1447
1448 return ret;
1449 }
1450
1452 if(data->have_locale) {
1453 free_locinfo(data->locinfo);
1454 free_mbcinfo(data->mbcinfo);
1455 data->locinfo = MSVCRT_locale->locinfo;
1456 data->mbcinfo = MSVCRT_locale->mbcinfo;
1457 data->have_locale = FALSE;
1458 }
1459
1460 return ret;
1461 }
1462
1463 if(!type)
1464 return ret;
1465
1466 return -1;
1467}
Definition: _locale.h:75
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define LC_ALL
Definition: locale.h:17
#define _DISABLE_PER_THREAD_LOCALE
Definition: locale.h:55
#define _ENABLE_PER_THREAD_LOCALE
Definition: locale.h:54
thread_data_t * msvcrt_get_thread_data(void)
Definition: tls.c:31
#define MSVCRT_free
Definition: msvcrt.h:152
void free_locinfo(MSVCRT_pthreadlocinfo locinfo)
Definition: locale.c:641
void free_mbcinfo(MSVCRT_pthreadmbcinfo mbcinfo)
Definition: locale.c:685
#define setlocale(n, s)
Definition: locale.h:46
int ret

◆ _Getdays()

char *CDECL _Getdays ( void  )

Definition at line 417 of file locale.c.

418{
420 int i, len, size;
421 char *out;
422
423 TRACE("\n");
424
425 size = cur->str.names.short_mon[0]-cur->str.names.short_wday[0];
427 if(!out)
428 return NULL;
429
430 size = 0;
431 for(i=0; i<7; i++) {
432 out[size++] = ':';
433 len = strlen(cur->str.names.short_wday[i]);
434 memcpy(&out[size], cur->str.names.short_wday[i], len);
435 size += len;
436
437 out[size++] = ':';
438 len = strlen(cur->str.names.wday[i]);
439 memcpy(&out[size], cur->str.names.wday[i], len);
440 size += len;
441 }
442 out[size] = '\0';
443
444 return out;
445}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
FxCollectionEntry * cur
GLsizeiptr size
Definition: glext.h:5919
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define MSVCRT_malloc
Definition: msvcrt.h:151
#define TRACE(s)
Definition: solgame.cpp:4
struct MSVCRT___lc_time_data * lc_time_curr
Definition: msvcrt.h:134

◆ _getmbcp()

◆ _Getmonths()

char *CDECL _Getmonths ( void  )

Definition at line 450 of file locale.c.

451{
453 int i, len, size;
454 char *out;
455
456 TRACE("\n");
457
458 size = cur->str.names.am-cur->str.names.short_mon[0];
460 if(!out)
461 return NULL;
462
463 size = 0;
464 for(i=0; i<12; i++) {
465 out[size++] = ':';
466 len = strlen(cur->str.names.short_mon[i]);
467 memcpy(&out[size], cur->str.names.short_mon[i], len);
468 size += len;
469
470 out[size++] = ':';
471 len = strlen(cur->str.names.mon[i]);
472 memcpy(&out[size], cur->str.names.mon[i], len);
473 size += len;
474 }
475 out[size] = '\0';
476
477 return out;
478}

◆ _Gettnames()

void *CDECL _Gettnames ( void  )

Definition at line 483 of file locale.c.

484{
486 unsigned int i, size = sizeof(MSVCRT___lc_time_data);
487
488 TRACE("\n");
489
490 for(i=0; i<sizeof(cur->str.str)/sizeof(cur->str.str[0]); i++)
491 size += strlen(cur->str.str[i])+1;
492
494 if(!ret)
495 return NULL;
496 memcpy(ret, cur, size);
497
498 size = 0;
499 for(i=0; i<sizeof(cur->str.str)/sizeof(cur->str.str[0]); i++) {
500 ret->str.str[i] = &ret->data[size];
501 size += strlen(&ret->data[size])+1;
502 }
503
504 return ret;
505}

Referenced by test__Gettnames().

◆ _wsetlocale()

wchar_t *CDECL _wsetlocale ( int  category,
const wchar_t locale 
)

Definition at line 403 of file locale.c.

404{
405 static wchar_t fake[] = {
406 'E','n','g','l','i','s','h','_','U','n','i','t','e','d',' ',
407 'S','t','a','t','e','s','.','1','2','5','2',0 };
408
409 FIXME("%d %s\n", category, debugstr_w(locale));
410
411 return fake;
412}

◆ atoi()

int atoi ( const char )

◆ compare_info()

static int compare_info ( LCID  lcid,
DWORD  flags,
char buff,
const char cmp,
BOOL  exact 
)
static

Definition at line 120 of file locale.c.

121{
122 int len;
123
124 if(!cmp[0])
125 return 0;
126
127 buff[0] = 0;
129 if (!buff[0])
130 return 0;
131
132 /* Partial matches are only allowed on language/country names */
133 len = strlen(cmp);
134 if(exact || len<=3)
135 return !strcasecmp(cmp, buff);
136 else
137 return !strncasecmp(cmp, buff, len);
138}
INT WINAPI GetLocaleInfoA(LCID lcid, LCTYPE lctype, LPSTR buffer, INT len)
Definition: locale.c:1599
#define strncasecmp
Definition: fake.h:10
#define strcasecmp
Definition: fake.h:9
static unsigned char buff[32768]
Definition: fatten.c:17
#define cmp(status, error)
Definition: error.c:114
#define MAX_ELEM_LEN
Definition: locale.c:27
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19

Referenced by ddraw_match_surface_desc(), and find_best_locale_proc().

◆ construct_lc_all()

static char * construct_lc_all ( MSVCRT_pthreadlocinfo  locinfo)
inlinestatic

Definition at line 374 of file locale.c.

374 {
375 static char current_lc_all[MAX_LOCALE_LENGTH];
376
377 int i;
378
379 for(i=MSVCRT_LC_MIN+1; i<MSVCRT_LC_MAX; i++) {
380 if(strcmp(locinfo->lc_category[i].locale,
381 locinfo->lc_category[i+1].locale))
382 break;
383 }
384
385 if(i==MSVCRT_LC_MAX)
386 return locinfo->lc_category[MSVCRT_LC_COLLATE].locale;
387
388 sprintf(current_lc_all,
389 "LC_COLLATE=%s;LC_CTYPE=%s;LC_MONETARY=%s;LC_NUMERIC=%s;LC_TIME=%s",
390 locinfo->lc_category[MSVCRT_LC_COLLATE].locale,
391 locinfo->lc_category[MSVCRT_LC_CTYPE].locale,
392 locinfo->lc_category[MSVCRT_LC_MONETARY].locale,
393 locinfo->lc_category[MSVCRT_LC_NUMERIC].locale,
394 locinfo->lc_category[MSVCRT_LC_TIME].locale);
395
396 return current_lc_all;
397}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define MSVCRT_LC_TIME
Definition: msvcrt.h:655
#define MSVCRT_LC_MAX
Definition: msvcrt.h:657
#define MSVCRT_LC_MONETARY
Definition: msvcrt.h:653
#define MSVCRT_LC_NUMERIC
Definition: msvcrt.h:654
#define MSVCRT_LC_COLLATE
Definition: msvcrt.h:651
#define MSVCRT_LC_MIN
Definition: msvcrt.h:656
#define MSVCRT_LC_CTYPE
Definition: msvcrt.h:652
else locinfo
Definition: scanf.h:159
#define MAX_LOCALE_LENGTH
Definition: locale.c:28

Referenced by setlocale().

◆ find_best_locale_proc()

static BOOL CALLBACK find_best_locale_proc ( HMODULE  hModule,
LPCSTR  type,
LPCSTR  name,
WORD  LangID,
LONG_PTR  lParam 
)
static

Definition at line 141 of file locale.c.

142{
144 const LCID lcid = MAKELCID(LangID, SORT_DEFAULT);
145 char buff[MAX_ELEM_LEN];
146 unsigned int flags = 0;
147
149 return CONTINUE_LOOKING;
150
151 /* Check Language */
152 if (compare_info(lcid,LOCALE_SISO639LANGNAME,buff,res->search_language, TRUE) ||
153 compare_info(lcid,LOCALE_SABBREVLANGNAME,buff,res->search_language, TRUE) ||
154 compare_info(lcid,LOCALE_SENGLANGUAGE,buff,res->search_language, FALSE))
155 {
156 TRACE(":Found language: %s->%s\n", res->search_language, buff);
158 }
159 else if (res->match_flags & FOUND_LANGUAGE)
160 {
161 return CONTINUE_LOOKING;
162 }
163
164 /* Check Country */
165 if (compare_info(lcid,LOCALE_SISO3166CTRYNAME,buff,res->search_country, TRUE) ||
166 compare_info(lcid,LOCALE_SABBREVCTRYNAME,buff,res->search_country, TRUE) ||
167 compare_info(lcid,LOCALE_SENGCOUNTRY,buff,res->search_country, FALSE))
168 {
169 TRACE("Found country:%s->%s\n", res->search_country, buff);
171 }
172 else if (!flags && (res->match_flags & FOUND_COUNTRY))
173 {
174 return CONTINUE_LOOKING;
175 }
176
177 /* Check codepage */
178 if (compare_info(lcid,LOCALE_IDEFAULTCODEPAGE,buff,res->search_codepage, TRUE) ||
179 (compare_info(lcid,LOCALE_IDEFAULTANSICODEPAGE,buff,res->search_codepage, TRUE)))
180 {
181 TRACE("Found codepage:%s->%s\n", res->search_codepage, buff);
183 memcpy(res->found_codepage,res->search_codepage,MAX_ELEM_LEN);
184 }
185 else if (!flags && (res->match_flags & FOUND_CODEPAGE))
186 {
187 return CONTINUE_LOOKING;
188 }
189
190 if (flags > res->match_flags)
191 {
192 /* Found a better match than previously */
193 res->match_flags = flags;
194 res->found_lang_id = LangID;
195 }
198 {
199 TRACE(":found exact locale match\n");
200 return STOP_LOOKING;
201 }
202 return CONTINUE_LOOKING;
203}
LPARAM lParam
Definition: combotst.c:139
GLuint res
Definition: glext.h:9613
#define SORT_DEFAULT
#define MAKELCID(lgid, srtid)
#define LANG_NEUTRAL
Definition: nls.h:22
DWORD LCID
Definition: nls.h:13
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define FOUND_LANGUAGE
Definition: locale.c:103
#define FOUND_CODEPAGE
Definition: locale.c:105
static int compare_info(LCID lcid, DWORD flags, char *buff, const char *cmp, BOOL exact)
Definition: locale.c:120
#define STOP_LOOKING
Definition: locale.c:117
#define FOUND_COUNTRY
Definition: locale.c:104
#define CONTINUE_LOOKING
Definition: locale.c:116
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1083
#define LOCALE_IDEFAULTCODEPAGE
Definition: winnls.h:37
#define LOCALE_SENGLANGUAGE
Definition: winnls.h:27
#define LOCALE_SISO639LANGNAME
Definition: winnls.h:126
#define LOCALE_IDEFAULTANSICODEPAGE
Definition: winnls.h:38
#define LOCALE_SISO3166CTRYNAME
Definition: winnls.h:127
#define LOCALE_SABBREVLANGNAME
Definition: winnls.h:28
#define LOCALE_SENGCOUNTRY
Definition: winnls.h:32
#define LOCALE_SABBREVCTRYNAME
Definition: winnls.h:33

Referenced by MSVCRT_locale_to_LCID().

◆ free_locinfo()

void free_locinfo ( MSVCRT_pthreadlocinfo  locinfo)

Definition at line 641 of file locale.c.

642{
643 int i;
644
645 if(!locinfo)
646 return;
647
648 if(InterlockedDecrement(&locinfo->refcount))
649 return;
650
651 for(i=MSVCRT_LC_MIN+1; i<=MSVCRT_LC_MAX; i++) {
652 MSVCRT_free(locinfo->lc_category[i].locale);
653 MSVCRT_free(locinfo->lc_category[i].refcount);
654 }
655
656 if(locinfo->lconv) {
657 MSVCRT_free(locinfo->lconv->decimal_point);
658 MSVCRT_free(locinfo->lconv->thousands_sep);
659 MSVCRT_free(locinfo->lconv->grouping);
660 MSVCRT_free(locinfo->lconv->int_curr_symbol);
661 MSVCRT_free(locinfo->lconv->currency_symbol);
662 MSVCRT_free(locinfo->lconv->mon_decimal_point);
663 MSVCRT_free(locinfo->lconv->mon_thousands_sep);
664 MSVCRT_free(locinfo->lconv->mon_grouping);
665 MSVCRT_free(locinfo->lconv->positive_sign);
666 MSVCRT_free(locinfo->lconv->negative_sign);
667 }
668 MSVCRT_free(locinfo->lconv_intl_refcount);
669 MSVCRT_free(locinfo->lconv_num_refcount);
670 MSVCRT_free(locinfo->lconv_mon_refcount);
671 MSVCRT_free(locinfo->lconv);
672
673 MSVCRT_free(locinfo->ctype1_refcount);
674 MSVCRT_free(locinfo->ctype1);
675
676 MSVCRT_free(locinfo->pclmap);
677 MSVCRT_free(locinfo->pcumap);
678
679 MSVCRT_free(locinfo->lc_time_curr);
680
682}
#define InterlockedDecrement
Definition: armddk.h:52

Referenced by _configthreadlocale(), and MSVCRT__free_locale().

◆ free_mbcinfo()

void free_mbcinfo ( MSVCRT_pthreadmbcinfo  mbcinfo)

Definition at line 685 of file locale.c.

686{
687 if(!mbcinfo)
688 return;
689
690 if(InterlockedDecrement(&mbcinfo->refcount))
691 return;
692
693 MSVCRT_free(mbcinfo);
694}

Referenced by _configthreadlocale(), and MSVCRT__free_locale().

◆ get_locinfo()

MSVCRT_pthreadlocinfo get_locinfo ( void  )

Definition at line 354 of file locale.c.

354 {
356
357 if(!data || !data->have_locale)
358 return MSVCRT_locale->locinfo;
359
360 return data->locinfo;
361}

Referenced by ___lc_collate_cp_func(), __p__pctype(), __pctype_func(), _Getdays(), _Getmonths(), _Gettnames(), localeconv(), MSVCRT__get_current_locale(), MSVCRT_btowc(), and setlocale().

◆ get_mbcinfo()

◆ localeconv()

struct lconv *CDECL localeconv ( void  )

Definition at line 601 of file locale.c.

602{
603 return (struct lconv*)get_locinfo()->lconv;
604}
struct MSVCRT_lconv * lconv
Definition: msvcrt.h:128
Definition: locale.h:29

Referenced by ftoes(), and ftofs().

◆ MSVCRT__create_locale()

MSVCRT__locale_t CDECL MSVCRT__create_locale ( int  category,
const char locale 
)

Definition at line 722 of file locale.c.

723{
724 static const DWORD time_data[] = {
740 };
741 static const char collate[] = "COLLATE=";
742 static const char ctype[] = "CTYPE=";
743 static const char monetary[] = "MONETARY=";
744 static const char numeric[] = "NUMERIC=";
745 static const char time[] = "TIME=";
746 static const char cloc_short_date[] = "MM/dd/yy";
747 static const wchar_t cloc_short_dateW[] = {'M','M','/','d','d','/','y','y',0};
748 static const char cloc_long_date[] = "dddd, MMMM dd, yyyy";
749 static const wchar_t cloc_long_dateW[] = {'d','d','d','d',',',' ','M','M','M','M',' ','d','d',',',' ','y','y','y','y',0};
750 static const char cloc_time[] = "HH:mm:ss";
751 static const wchar_t cloc_timeW[] = {'H','H',':','m','m',':','s','s',0};
752
754 LCID lcid[6] = { 0 }, lcid_tmp;
755 unsigned short cp[6] = { 0 };
756 char buf[256];
757 int i, ret, size;
758
759 TRACE("(%d %s)\n", category, locale);
760
762 return NULL;
763
764 if(locale[0]=='C' && !locale[1]) {
765 lcid[0] = 0;
766 cp[0] = CP_ACP;
767 } else if(!locale[0]) {
768 lcid[0] = GetSystemDefaultLCID();
770 |LOCALE_NOUSEROVERRIDE, buf, sizeof(buf));
771 cp[0] = atoi(buf);
772
773 for(i=1; i<6; i++) {
774 lcid[i] = lcid[0];
775 cp[i] = cp[0];
776 }
777 } else if (locale[0] == 'L' && locale[1] == 'C' && locale[2] == '_') {
778 const char *p;
779
780 while(1) {
781 locale += 3; /* LC_ */
782 if(!memcmp(locale, collate, sizeof(collate)-1)) {
784 locale += sizeof(collate)-1;
785 } else if(!memcmp(locale, ctype, sizeof(ctype)-1)) {
787 locale += sizeof(ctype)-1;
788 } else if(!memcmp(locale, monetary, sizeof(monetary)-1)) {
790 locale += sizeof(monetary)-1;
791 } else if(!memcmp(locale, numeric, sizeof(numeric)-1)) {
793 locale += sizeof(numeric)-1;
794 } else if(!memcmp(locale, time, sizeof(time)-1)) {
796 locale += sizeof(time)-1;
797 } else
798 return NULL;
799
800 p = strchr(locale, ';');
801 if(locale[0]=='C' && (locale[1]==';' || locale[1]=='\0')) {
802 lcid[i] = 0;
803 cp[i] = CP_ACP;
804 } else if(p) {
806 buf[p-locale] = '\0';
807 lcid[i] = MSVCRT_locale_to_LCID(buf, &cp[i]);
808 } else
809 lcid[i] = MSVCRT_locale_to_LCID(locale, &cp[i]);
810
811 if(lcid[i] == -1)
812 return NULL;
813
814 if(!p || *(p+1)!='L' || *(p+2)!='C' || *(p+3)!='_')
815 break;
816
817 locale = p+1;
818 }
819 } else {
820 lcid[0] = MSVCRT_locale_to_LCID(locale, &cp[0]);
821 if(lcid[0] == -1)
822 return NULL;
823
824 for(i=1; i<6; i++) {
825 lcid[i] = lcid[0];
826 cp[i] = cp[0];
827 }
828 }
829
831 if(!loc)
832 return NULL;
833
835 if(!loc->locinfo) {
836 MSVCRT_free(loc);
837 return NULL;
838 }
839
841 if(!loc->mbcinfo) {
842 MSVCRT_free(loc->locinfo);
843 MSVCRT_free(loc);
844 return NULL;
845 }
846
847 memset(loc->locinfo, 0, sizeof(MSVCRT_threadlocinfo));
848 loc->locinfo->refcount = 1;
849 loc->mbcinfo->refcount = 1;
850
851 loc->locinfo->lconv = MSVCRT_malloc(sizeof(struct MSVCRT_lconv));
852 if(!loc->locinfo->lconv) {
854 return NULL;
855 }
856 memset(loc->locinfo->lconv, 0, sizeof(struct MSVCRT_lconv));
857
858 loc->locinfo->pclmap = MSVCRT_malloc(sizeof(char[256]));
859 loc->locinfo->pcumap = MSVCRT_malloc(sizeof(char[256]));
860 if(!loc->locinfo->pclmap || !loc->locinfo->pcumap) {
862 return NULL;
863 }
864
868 return NULL;
869 }
870
872 } else
873 loc->locinfo->lc_category[LC_COLLATE].locale = _strdup("C");
874
877 int j;
878
881 return NULL;
882 }
883
885 loc->locinfo->lc_clike = 1;
886 if(!GetCPInfo(loc->locinfo->lc_codepage, &cp_info)) {
888 return NULL;
889 }
890 loc->locinfo->mb_cur_max = cp_info.MaxCharSize;
891
892 loc->locinfo->ctype1_refcount = MSVCRT_malloc(sizeof(int));
893 loc->locinfo->ctype1 = MSVCRT_malloc(sizeof(short[257]));
894 if(!loc->locinfo->ctype1_refcount || !loc->locinfo->ctype1) {
896 return NULL;
897 }
898
899 *loc->locinfo->ctype1_refcount = 1;
900 loc->locinfo->ctype1[0] = 0;
901 loc->locinfo->pctype = loc->locinfo->ctype1+1;
902
903 buf[1] = buf[2] = '\0';
904 for(i=1; i<257; i++) {
905 buf[0] = i-1;
906
907 /* builtin GetStringTypeA doesn't set output to 0 on invalid input */
908 loc->locinfo->ctype1[i] = 0;
909
911 1, loc->locinfo->ctype1+i);
912 }
913
914 for(i=0; cp_info.LeadByte[i+1]!=0; i+=2)
915 for(j=cp_info.LeadByte[i]; j<=cp_info.LeadByte[i+1]; j++)
916 loc->locinfo->ctype1[j+1] |= _LEADBYTE;
917 } else {
918 loc->locinfo->lc_clike = 1;
919 loc->locinfo->mb_cur_max = 1;
920 loc->locinfo->pctype = _ctype+1;
921 loc->locinfo->lc_category[LC_CTYPE].locale = _strdup("C");
922 }
923
924 for(i=0; i<256; i++) {
925 if(loc->locinfo->pctype[i] & _LEADBYTE)
926 buf[i] = ' ';
927 else
928 buf[i] = i;
929
930 }
931
932 if(lcid[MSVCRT_LC_CTYPE]) {
934 (char*)loc->locinfo->pclmap, 256);
936 (char*)loc->locinfo->pcumap, 256);
937 } else {
938 for(i=0; i<256; i++) {
939 loc->locinfo->pclmap[i] = (i>='A' && i<='Z' ? i-'A'+'a' : i);
940 loc->locinfo->pcumap[i] = (i>='a' && i<='z' ? i-'a'+'A' : i);
941 }
942 }
943
945
949 return NULL;
950 }
951
952 loc->locinfo->lconv_intl_refcount = MSVCRT_malloc(sizeof(int));
953 loc->locinfo->lconv_mon_refcount = MSVCRT_malloc(sizeof(int));
956 return NULL;
957 }
958
959 *loc->locinfo->lconv_intl_refcount = 1;
960 *loc->locinfo->lconv_mon_refcount = 1;
961
964 if(i && (loc->locinfo->lconv->int_curr_symbol = MSVCRT_malloc(i)))
965 memcpy(loc->locinfo->lconv->int_curr_symbol, buf, i);
966 else {
968 return NULL;
969 }
970
973 if(i && (loc->locinfo->lconv->currency_symbol = MSVCRT_malloc(i)))
974 memcpy(loc->locinfo->lconv->currency_symbol, buf, i);
975 else {
977 return NULL;
978 }
979
982 if(i && (loc->locinfo->lconv->mon_decimal_point = MSVCRT_malloc(i)))
983 memcpy(loc->locinfo->lconv->mon_decimal_point, buf, i);
984 else {
986 return NULL;
987 }
988
991 if(i && (loc->locinfo->lconv->mon_thousands_sep = MSVCRT_malloc(i)))
992 memcpy(loc->locinfo->lconv->mon_thousands_sep, buf, i);
993 else {
995 return NULL;
996 }
997
1000 if(i>1)
1001 i = i/2 + (buf[i-2]=='0'?0:1);
1002 if(i && (loc->locinfo->lconv->mon_grouping = MSVCRT_malloc(i))) {
1003 for(i=0; buf[i+1]==';'; i+=2)
1004 loc->locinfo->lconv->mon_grouping[i/2] = buf[i]-'0';
1005 loc->locinfo->lconv->mon_grouping[i/2] = buf[i]-'0';
1006 if(buf[i] != '0')
1007 loc->locinfo->lconv->mon_grouping[i/2+1] = 127;
1008 } else {
1010 return NULL;
1011 }
1012
1014 |LOCALE_NOUSEROVERRIDE, buf, 256);
1015 if(i && (loc->locinfo->lconv->positive_sign = MSVCRT_malloc(i)))
1016 memcpy(loc->locinfo->lconv->positive_sign, buf, i);
1017 else {
1019 return NULL;
1020 }
1021
1023 |LOCALE_NOUSEROVERRIDE, buf, 256);
1024 if(i && (loc->locinfo->lconv->negative_sign = MSVCRT_malloc(i)))
1025 memcpy(loc->locinfo->lconv->negative_sign, buf, i);
1026 else {
1028 return NULL;
1029 }
1030
1032 |LOCALE_NOUSEROVERRIDE, buf, 256))
1033 loc->locinfo->lconv->int_frac_digits = atoi(buf);
1034 else {
1036 return NULL;
1037 }
1038
1040 |LOCALE_NOUSEROVERRIDE, buf, 256))
1041 loc->locinfo->lconv->frac_digits = atoi(buf);
1042 else {
1044 return NULL;
1045 }
1046
1048 |LOCALE_NOUSEROVERRIDE, buf, 256))
1049 loc->locinfo->lconv->p_cs_precedes = atoi(buf);
1050 else {
1052 return NULL;
1053 }
1054
1056 |LOCALE_NOUSEROVERRIDE, buf, 256))
1057 loc->locinfo->lconv->p_sep_by_space = atoi(buf);
1058 else {
1060 return NULL;
1061 }
1062
1064 |LOCALE_NOUSEROVERRIDE, buf, 256))
1065 loc->locinfo->lconv->n_cs_precedes = atoi(buf);
1066 else {
1068 return NULL;
1069 }
1070
1072 |LOCALE_NOUSEROVERRIDE, buf, 256))
1073 loc->locinfo->lconv->n_sep_by_space = atoi(buf);
1074 else {
1076 return NULL;
1077 }
1078
1080 |LOCALE_NOUSEROVERRIDE, buf, 256))
1081 loc->locinfo->lconv->p_sign_posn = atoi(buf);
1082 else {
1084 return NULL;
1085 }
1086
1088 |LOCALE_NOUSEROVERRIDE, buf, 256))
1089 loc->locinfo->lconv->n_sign_posn = atoi(buf);
1090 else {
1092 return NULL;
1093 }
1094 } else {
1095 loc->locinfo->lconv->int_curr_symbol = MSVCRT_malloc(sizeof(char));
1096 loc->locinfo->lconv->currency_symbol = MSVCRT_malloc(sizeof(char));
1097 loc->locinfo->lconv->mon_decimal_point = MSVCRT_malloc(sizeof(char));
1098 loc->locinfo->lconv->mon_thousands_sep = MSVCRT_malloc(sizeof(char));
1099 loc->locinfo->lconv->mon_grouping = MSVCRT_malloc(sizeof(char));
1100 loc->locinfo->lconv->positive_sign = MSVCRT_malloc(sizeof(char));
1101 loc->locinfo->lconv->negative_sign = MSVCRT_malloc(sizeof(char));
1102
1103 if(!loc->locinfo->lconv->int_curr_symbol || !loc->locinfo->lconv->currency_symbol
1104 || !loc->locinfo->lconv->mon_decimal_point || !loc->locinfo->lconv->mon_thousands_sep
1105 || !loc->locinfo->lconv->mon_grouping || !loc->locinfo->lconv->positive_sign
1106 || !loc->locinfo->lconv->negative_sign) {
1108 return NULL;
1109 }
1110
1111 loc->locinfo->lconv->int_curr_symbol[0] = '\0';
1112 loc->locinfo->lconv->currency_symbol[0] = '\0';
1113 loc->locinfo->lconv->mon_decimal_point[0] = '\0';
1114 loc->locinfo->lconv->mon_thousands_sep[0] = '\0';
1115 loc->locinfo->lconv->mon_grouping[0] = '\0';
1116 loc->locinfo->lconv->positive_sign[0] = '\0';
1117 loc->locinfo->lconv->negative_sign[0] = '\0';
1118 loc->locinfo->lconv->int_frac_digits = 127;
1119 loc->locinfo->lconv->frac_digits = 127;
1120 loc->locinfo->lconv->p_cs_precedes = 127;
1121 loc->locinfo->lconv->p_sep_by_space = 127;
1122 loc->locinfo->lconv->n_cs_precedes = 127;
1123 loc->locinfo->lconv->n_sep_by_space = 127;
1124 loc->locinfo->lconv->p_sign_posn = 127;
1125 loc->locinfo->lconv->n_sign_posn = 127;
1126
1127 loc->locinfo->lc_category[LC_MONETARY].locale = _strdup("C");
1128 }
1129
1133 return NULL;
1134 }
1135
1136 if(!loc->locinfo->lconv_intl_refcount)
1137 loc->locinfo->lconv_intl_refcount = MSVCRT_malloc(sizeof(int));
1138 loc->locinfo->lconv_num_refcount = MSVCRT_malloc(sizeof(int));
1141 return NULL;
1142 }
1143
1144 *loc->locinfo->lconv_intl_refcount = 1;
1145 *loc->locinfo->lconv_num_refcount = 1;
1146
1148 |LOCALE_NOUSEROVERRIDE, buf, 256);
1149 if(i && (loc->locinfo->lconv->decimal_point = MSVCRT_malloc(i)))
1150 memcpy(loc->locinfo->lconv->decimal_point, buf, i);
1151 else {
1153 return NULL;
1154 }
1155
1157 |LOCALE_NOUSEROVERRIDE, buf, 256);
1158 if(i && (loc->locinfo->lconv->thousands_sep = MSVCRT_malloc(i)))
1159 memcpy(loc->locinfo->lconv->thousands_sep, buf, i);
1160 else {
1162 return NULL;
1163 }
1164
1166 |LOCALE_NOUSEROVERRIDE, buf, 256);
1167 if(i>1)
1168 i = i/2 + (buf[i-2]=='0'?0:1);
1169 if(i && (loc->locinfo->lconv->grouping = MSVCRT_malloc(i))) {
1170 for(i=0; buf[i+1]==';'; i+=2)
1171 loc->locinfo->lconv->grouping[i/2] = buf[i]-'0';
1172 loc->locinfo->lconv->grouping[i/2] = buf[i]-'0';
1173 if(buf[i] != '0')
1174 loc->locinfo->lconv->grouping[i/2+1] = 127;
1175 } else {
1177 return NULL;
1178 }
1179 } else {
1180 loc->locinfo->lconv->decimal_point = MSVCRT_malloc(sizeof(char[2]));
1181 loc->locinfo->lconv->thousands_sep = MSVCRT_malloc(sizeof(char));
1182 loc->locinfo->lconv->grouping = MSVCRT_malloc(sizeof(char));
1183 if(!loc->locinfo->lconv->decimal_point || !loc->locinfo->lconv->thousands_sep
1184 || !loc->locinfo->lconv->grouping) {
1186 return NULL;
1187 }
1188
1189 loc->locinfo->lconv->decimal_point[0] = '.';
1190 loc->locinfo->lconv->decimal_point[1] = '\0';
1191 loc->locinfo->lconv->thousands_sep[0] = '\0';
1192 loc->locinfo->lconv->grouping[0] = '\0';
1193
1194 loc->locinfo->lc_category[LC_NUMERIC].locale = _strdup("C");
1195 }
1196
1200 return NULL;
1201 }
1202 } else
1203 loc->locinfo->lc_category[LC_TIME].locale = _strdup("C");
1204
1205 size = sizeof(MSVCRT___lc_time_data);
1206 lcid_tmp = lcid[MSVCRT_LC_TIME] ? lcid[MSVCRT_LC_TIME] : MAKELCID(LANG_ENGLISH, SORT_DEFAULT);
1207 for(i=0; i<sizeof(time_data)/sizeof(time_data[0]); i++) {
1208 if(time_data[i]==LOCALE_SSHORTDATE && !lcid[MSVCRT_LC_TIME]) {
1209 size += sizeof(cloc_short_date) + sizeof(cloc_short_dateW);
1210 }else if(time_data[i]==LOCALE_SLONGDATE && !lcid[MSVCRT_LC_TIME]) {
1211 size += sizeof(cloc_long_date) + sizeof(cloc_long_dateW);
1212 }else {
1213 ret = GetLocaleInfoA(lcid_tmp, time_data[i]
1215 if(!ret) {
1217 return NULL;
1218 }
1219 size += ret;
1220
1221 ret = GetLocaleInfoW(lcid_tmp, time_data[i]
1223 if(!ret) {
1225 return NULL;
1226 }
1227 size += ret*sizeof(wchar_t);
1228 }
1229 }
1230
1232 if(!loc->locinfo->lc_time_curr) {
1234 return NULL;
1235 }
1236
1237 ret = 0;
1238 for(i=0; i<sizeof(time_data)/sizeof(time_data[0]); i++) {
1239 loc->locinfo->lc_time_curr->str.str[i] = &loc->locinfo->lc_time_curr->data[ret];
1240 if(time_data[i]==LOCALE_SSHORTDATE && !lcid[MSVCRT_LC_TIME]) {
1241 memcpy(&loc->locinfo->lc_time_curr->data[ret], cloc_short_date, sizeof(cloc_short_date));
1242 ret += sizeof(cloc_short_date);
1243 }else if(time_data[i]==LOCALE_SLONGDATE && !lcid[MSVCRT_LC_TIME]) {
1244 memcpy(&loc->locinfo->lc_time_curr->data[ret], cloc_long_date, sizeof(cloc_long_date));
1245 ret += sizeof(cloc_long_date);
1246 }else if(time_data[i]==LOCALE_STIMEFORMAT && !lcid[MSVCRT_LC_TIME]) {
1247 memcpy(&loc->locinfo->lc_time_curr->data[ret], cloc_time, sizeof(cloc_time));
1248 ret += sizeof(cloc_time);
1249 }else {
1250 ret += GetLocaleInfoA(lcid_tmp, time_data[i]|LOCALE_NOUSEROVERRIDE,
1251 &loc->locinfo->lc_time_curr->data[ret], size-ret);
1252 }
1253 }
1254 for(i=0; i<sizeof(time_data)/sizeof(time_data[0]); i++) {
1255 loc->locinfo->lc_time_curr->wstr[i] = (wchar_t*)&loc->locinfo->lc_time_curr->data[ret];
1256 if(time_data[i]==LOCALE_SSHORTDATE && !lcid[MSVCRT_LC_TIME]) {
1257 memcpy(&loc->locinfo->lc_time_curr->data[ret], cloc_short_dateW, sizeof(cloc_short_dateW));
1258 ret += sizeof(cloc_short_dateW);
1259 }else if(time_data[i]==LOCALE_SLONGDATE && !lcid[MSVCRT_LC_TIME]) {
1260 memcpy(&loc->locinfo->lc_time_curr->data[ret], cloc_long_dateW, sizeof(cloc_long_dateW));
1261 ret += sizeof(cloc_long_dateW);
1262 }else if(time_data[i]==LOCALE_STIMEFORMAT && !lcid[MSVCRT_LC_TIME]) { memcpy(&loc->locinfo->lc_time_curr->data[ret], cloc_timeW, sizeof(cloc_timeW));
1263 ret += sizeof(cloc_timeW);
1264 }else {
1265 ret += GetLocaleInfoW(lcid_tmp, time_data[i]|LOCALE_NOUSEROVERRIDE,
1266 (wchar_t*)&loc->locinfo->lc_time_curr->data[ret], size-ret)*sizeof(wchar_t);
1267 }
1268 }
1269 loc->locinfo->lc_time_curr->lcid = lcid[MSVCRT_LC_TIME];
1270
1271 return loc;
1272}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
char * strchr(const char *String, int ch)
Definition: utclib.c:501
Definition: _ctype.h:58
#define _strdup
Definition: debug_ros.c:7
#define CP_ACP
Definition: compat.h:109
BOOL WINAPI GetStringTypeA(LCID locale, DWORD type, LPCSTR src, INT count, LPWORD chartype)
Definition: locale.c:3208
BOOL WINAPI GetCPInfo(UINT codepage, LPCPINFO cpinfo)
Definition: locale.c:2143
LCID WINAPI GetSystemDefaultLCID(void)
Definition: locale.c:1229
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define _LEADBYTE
Definition: ctype.h:75
#define LC_CTYPE
Definition: locale.h:19
#define LC_NUMERIC
Definition: locale.h:21
#define LC_MONETARY
Definition: locale.h:20
#define LC_TIME
Definition: locale.h:22
#define LC_COLLATE
Definition: locale.h:18
POINT cp
Definition: magnifier.c:59
__u16 time
Definition: mkdosfs.c:8
int _setmbcp_l(int, LCID, MSVCRT_pthreadmbcinfo)
Definition: _setmbcp.c:52
#define MSVCRT_LC_ALL
Definition: msvcrt.h:650
#define LANG_ENGLISH
Definition: nls.h:52
const unsigned short _ctype[257]
Definition: ctype.c:36
void CDECL MSVCRT__free_locale(MSVCRT__locale_t locale)
Definition: locale.c:711
int atoi(const char *)
static BOOL update_threadlocinfo_category(LCID lcid, unsigned short cp, MSVCRT__locale_t loc, int category)
Definition: locale.c:289
LCID MSVCRT_locale_to_LCID(const char *locale, unsigned short *codepage)
Definition: locale.c:208
#define memset(x, y, z)
Definition: compat.h:39
MSVCRT_pthreadmbcinfo mbcinfo
Definition: msvcrt.h:153
MSVCRT_pthreadlocinfo locinfo
Definition: msvcrt.h:152
unsigned short wCodePage
Definition: msvcrt.h:108
MSVCRT_LC_ID lc_id[6]
Definition: msvcrt.h:116
unsigned int lc_codepage
Definition: msvcrt.h:113
unsigned char * pclmap
Definition: msvcrt.h:132
unsigned char * pcumap
Definition: msvcrt.h:133
unsigned short * ctype1
Definition: msvcrt.h:130
struct MSVCRT_threadlocaleinfostruct::@1691 lc_category[6]
#define wchar_t
Definition: wchar.h:102
#define LOCALE_SABBREVMONTHNAME10
Definition: winnls.h:113
#define LOCALE_SMONTHNAME12
Definition: winnls.h:102
#define LOCALE_ICURRDIGITS
Definition: winnls.h:54
#define LOCALE_SMONTHNAME5
Definition: winnls.h:95
#define LOCALE_SDAYNAME5
Definition: winnls.h:81
#define LOCALE_SABBREVMONTHNAME9
Definition: winnls.h:112
#define LOCALE_SABBREVMONTHNAME11
Definition: winnls.h:114
#define LOCALE_SABBREVDAYNAME5
Definition: winnls.h:88
#define LOCALE_SABBREVDAYNAME2
Definition: winnls.h:85
#define LOCALE_INEGSEPBYSPACE
Definition: winnls.h:124
#define LOCALE_SABBREVMONTHNAME2
Definition: winnls.h:105
#define LOCALE_INEGSIGNPOSN
Definition: winnls.h:120
#define LOCALE_SGROUPING
Definition: winnls.h:44
#define LOCALE_SMONTHNAME3
Definition: winnls.h:93
#define LOCALE_SDECIMAL
Definition: winnls.h:42
#define LOCALE_SMONTHNAME11
Definition: winnls.h:101
#define LOCALE_SMONTHNAME8
Definition: winnls.h:98
#define CT_CTYPE1
Definition: winnls.h:237
#define LOCALE_SMONTHNAME4
Definition: winnls.h:94
#define LOCALE_SDAYNAME1
Definition: winnls.h:77
#define LCMAP_UPPERCASE
Definition: winnls.h:185
#define LOCALE_SLONGDATE
Definition: winnls.h:61
#define LOCALE_SMONTHNAME7
Definition: winnls.h:97
#define LOCALE_IINTLCURRDIGITS
Definition: winnls.h:55
#define LOCALE_S1159
Definition: winnls.h:71
#define LOCALE_SSHORTDATE
Definition: winnls.h:60
#define LOCALE_IPOSSYMPRECEDES
Definition: winnls.h:121
#define LOCALE_SABBREVMONTHNAME4
Definition: winnls.h:107
#define LOCALE_SPOSITIVESIGN
Definition: winnls.h:117
#define LOCALE_SABBREVDAYNAME4
Definition: winnls.h:87
#define LOCALE_SMONDECIMALSEP
Definition: winnls.h:51
#define LCMAP_LOWERCASE
Definition: winnls.h:184
#define LOCALE_SMONTHNAME1
Definition: winnls.h:91
#define LOCALE_SABBREVMONTHNAME3
Definition: winnls.h:106
#define LOCALE_INEGSYMPRECEDES
Definition: winnls.h:123
#define LOCALE_SMONTHOUSANDSEP
Definition: winnls.h:52
#define LOCALE_SDAYNAME7
Definition: winnls.h:83
#define LOCALE_IPOSSIGNPOSN
Definition: winnls.h:119
#define LOCALE_SDAYNAME2
Definition: winnls.h:78
#define LOCALE_SABBREVMONTHNAME1
Definition: winnls.h:104
#define LOCALE_STHOUSAND
Definition: winnls.h:43
#define LOCALE_SABBREVDAYNAME6
Definition: winnls.h:89
#define LOCALE_SMONTHNAME2
Definition: winnls.h:92
#define LOCALE_STIMEFORMAT
Definition: winnls.h:62
#define LOCALE_SABBREVDAYNAME1
Definition: winnls.h:84
#define LOCALE_SABBREVMONTHNAME6
Definition: winnls.h:109
#define LOCALE_SMONTHNAME6
Definition: winnls.h:96
#define LOCALE_SNEGATIVESIGN
Definition: winnls.h:118
#define LOCALE_SDAYNAME3
Definition: winnls.h:79
#define LOCALE_S2359
Definition: winnls.h:72
#define LOCALE_SABBREVDAYNAME3
Definition: winnls.h:86
#define LOCALE_SABBREVMONTHNAME5
Definition: winnls.h:108
#define LOCALE_SABBREVMONTHNAME7
Definition: winnls.h:110
#define LOCALE_SINTLSYMBOL
Definition: winnls.h:50
#define LOCALE_SABBREVMONTHNAME8
Definition: winnls.h:111
#define LOCALE_SMONGROUPING
Definition: winnls.h:53
#define LOCALE_SDAYNAME4
Definition: winnls.h:80
#define LOCALE_SCURRENCY
Definition: winnls.h:49
#define LOCALE_SMONTHNAME10
Definition: winnls.h:100
#define LOCALE_SMONTHNAME9
Definition: winnls.h:99
#define LOCALE_IPOSSEPBYSPACE
Definition: winnls.h:122
#define LOCALE_SABBREVMONTHNAME12
Definition: winnls.h:115
#define LOCALE_SDAYNAME6
Definition: winnls.h:82
#define LOCALE_SABBREVDAYNAME7
Definition: winnls.h:90

Referenced by __init_global_locale(), _configthreadlocale(), and setlocale().

◆ MSVCRT__free_locale()

void CDECL MSVCRT__free_locale ( MSVCRT__locale_t  locale)

Definition at line 711 of file locale.c.

712{
713 if (!locale)
714 return;
715
716 free_locinfo(locale->locinfo);
717 free_mbcinfo(locale->mbcinfo);
719}

Referenced by DllMain(), MSVCRT__create_locale(), msvcrt_init_exception(), and setlocale().

◆ MSVCRT__get_current_locale()

MSVCRT__locale_t CDECL MSVCRT__get_current_locale ( void  )

Definition at line 697 of file locale.c.

698{
700 if(!loc)
701 return NULL;
702
703 loc->locinfo = get_locinfo();
704 loc->mbcinfo = get_mbcinfo();
707 return loc;
708}
#define InterlockedIncrement
Definition: armddk.h:53

◆ MSVCRT_btowc()

wint_t CDECL MSVCRT_btowc ( int  c)

Definition at line 571 of file locale.c.

572{
573 unsigned char letter = c;
574 wchar_t ret;
575
576 if(!MultiByteToWideChar(get_locinfo()->lc_handle[LC_CTYPE],
577 0, (LPCSTR)&letter, 1, &ret, 1))
578 return 0;
579
580 return ret;
581}
#define MultiByteToWideChar
Definition: compat.h:110
#define c
Definition: ke_i.h:80
const char * LPCSTR
Definition: xmlstorage.h:183

◆ MSVCRT_locale_to_LCID()

LCID MSVCRT_locale_to_LCID ( const char locale,
unsigned short codepage 
)

Definition at line 208 of file locale.c.

209{
210 LCID lcid;
212 const char *cp, *region;
213
214 memset(&search, 0, sizeof(locale_search_t));
215
216 cp = strchr(locale, '.');
217 region = strchr(locale, '_');
218
219 lstrcpynA(search.search_language, locale, MAX_ELEM_LEN);
220 if(region) {
221 lstrcpynA(search.search_country, region+1, MAX_ELEM_LEN);
222 if(region-locale < MAX_ELEM_LEN)
223 search.search_language[region-locale] = '\0';
224 } else
225 search.search_country[0] = '\0';
226
227 if(cp) {
228 lstrcpynA(search.search_codepage, cp+1, MAX_ELEM_LEN);
229 if(region && cp-region-1<MAX_ELEM_LEN)
230 search.search_country[cp-region-1] = '\0';
232 search.search_language[cp-locale] = '\0';
233 } else
234 search.search_codepage[0] = '\0';
235
236 if(!search.search_country[0] && !search.search_codepage[0])
237 remap_synonym(search.search_language);
238
241 (LONG_PTR)&search);
242
243 if (!search.match_flags)
244 return -1;
245
246 /* If we were given something that didn't match, fail */
247 if (search.search_country[0] && !(search.match_flags & FOUND_COUNTRY))
248 return -1;
249
250 lcid = MAKELCID(search.found_lang_id, SORT_DEFAULT);
251
252 /* Populate partial locale, translating LCID to locale string elements */
253 if (!(search.match_flags & FOUND_CODEPAGE)) {
254 /* Even if a codepage is not enumerated for a locale
255 * it can be set if valid */
256 if (search.search_codepage[0]) {
257 if (IsValidCodePage(atoi(search.search_codepage)))
258 memcpy(search.found_codepage,search.search_codepage,MAX_ELEM_LEN);
259 else {
260 /* Special codepage values: OEM & ANSI */
261 if (!strcasecmp(search.search_codepage,"OCP")) {
263 search.found_codepage, MAX_ELEM_LEN);
264 } else if (!strcasecmp(search.search_codepage,"ACP")) {
266 search.found_codepage, MAX_ELEM_LEN);
267 } else
268 return -1;
269
270 if (!atoi(search.found_codepage))
271 return -1;
272 }
273 } else {
274 /* Prefer ANSI codepages if present */
276 search.found_codepage, MAX_ELEM_LEN);
277 if (!search.found_codepage[0] || !atoi(search.found_codepage))
279 search.found_codepage, MAX_ELEM_LEN);
280 }
281 }
282 if (codepage)
283 *codepage = atoi(search.found_codepage);
284
285 return lcid;
286}
#define lstrcpynA
Definition: compat.h:751
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
BOOL WINAPI EnumResourceLanguagesA(HMODULE hmod, LPCSTR type, LPCSTR name, ENUMRESLANGPROCA lpfun, LONG_PTR lparam)
Definition: res.c:428
BOOL WINAPI IsValidCodePage(UINT codepage)
Definition: locale.c:2078
static short search(int val, const short *table, int size)
Definition: msg711.c:255
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define RT_STRING
Definition: pedump.c:368
static void remap_synonym(char *name)
Definition: locale.c:88
static BOOL CALLBACK find_best_locale_proc(HMODULE hModule, LPCSTR type, LPCSTR name, WORD LangID, LONG_PTR lParam)
Definition: locale.c:141
#define LOCALE_ILANGUAGE
Definition: winnls.h:25
char * LPSTR
Definition: xmlstorage.h:182

Referenced by MSVCRT__create_locale().

◆ remap_synonym()

static void remap_synonym ( char name)
static

Definition at line 88 of file locale.c.

89{
90 unsigned int i;
91 for (i = 0; i < sizeof(_country_synonyms)/sizeof(char*); i += 2 )
92 {
94 {
95 TRACE(":Mapping synonym %s to %s\n",name,_country_synonyms[i+1]);
97 return;
98 }
99 }
100}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static const char *const _country_synonyms[]
Definition: locale.c:50
Definition: name.c:39

Referenced by MSVCRT_locale_to_LCID().

◆ setlocale()

char *CDECL setlocale ( int  category,
const char locale 
)

Definition at line 1277 of file locale.c.

1278{
1279 MSVCRT__locale_t loc;
1281
1283 return NULL;
1284
1285 if(!locale) {
1286 if(category == MSVCRT_LC_ALL)
1287 return construct_lc_all(locinfo);
1288
1289 return locinfo->lc_category[category].locale;
1290 }
1291
1293 if(!loc) {
1294 WARN("%d %s failed\n", category, locale);
1295 return NULL;
1296 }
1297
1299
1300 switch(category) {
1301 case MSVCRT_LC_ALL:
1302 case MSVCRT_LC_COLLATE:
1303 locinfo->lc_collate_cp = loc->locinfo->lc_collate_cp;
1304 locinfo->lc_handle[MSVCRT_LC_COLLATE] =
1306 swap_pointers((void**)&locinfo->lc_category[MSVCRT_LC_COLLATE].locale,
1307 (void**)&loc->locinfo->lc_category[MSVCRT_LC_COLLATE].locale);
1308 swap_pointers((void**)&locinfo->lc_category[MSVCRT_LC_COLLATE].refcount,
1309 (void**)&loc->locinfo->lc_category[MSVCRT_LC_COLLATE].refcount);
1310
1311 if(category != MSVCRT_LC_ALL)
1312 break;
1313 /* fall through */
1314 case MSVCRT_LC_CTYPE:
1315 locinfo->lc_handle[MSVCRT_LC_CTYPE] =
1317 swap_pointers((void**)&locinfo->lc_category[MSVCRT_LC_CTYPE].locale,
1318 (void**)&loc->locinfo->lc_category[MSVCRT_LC_CTYPE].locale);
1319 swap_pointers((void**)&locinfo->lc_category[MSVCRT_LC_CTYPE].refcount,
1320 (void**)&loc->locinfo->lc_category[MSVCRT_LC_CTYPE].refcount);
1321
1322 locinfo->lc_codepage = loc->locinfo->lc_codepage;
1323 locinfo->lc_clike = loc->locinfo->lc_clike;
1324 locinfo->mb_cur_max = loc->locinfo->mb_cur_max;
1325
1326 swap_pointers((void**)&locinfo->ctype1_refcount,
1327 (void**)&loc->locinfo->ctype1_refcount);
1328 swap_pointers((void**)&locinfo->ctype1, (void**)&loc->locinfo->ctype1);
1329 swap_pointers((void**)&locinfo->pctype, (void**)&loc->locinfo->pctype);
1330 swap_pointers((void**)&locinfo->pclmap, (void**)&loc->locinfo->pclmap);
1331 swap_pointers((void**)&locinfo->pcumap, (void**)&loc->locinfo->pcumap);
1332
1333 if(category != MSVCRT_LC_ALL)
1334 break;
1335 /* fall through */
1336 case MSVCRT_LC_MONETARY:
1337 locinfo->lc_handle[MSVCRT_LC_MONETARY] =
1339 swap_pointers((void**)&locinfo->lc_category[MSVCRT_LC_MONETARY].locale,
1340 (void**)&loc->locinfo->lc_category[MSVCRT_LC_MONETARY].locale);
1341 swap_pointers((void**)&locinfo->lc_category[MSVCRT_LC_MONETARY].refcount,
1342 (void**)&loc->locinfo->lc_category[MSVCRT_LC_MONETARY].refcount);
1343
1344 swap_pointers((void**)&locinfo->lconv->int_curr_symbol,
1345 (void**)&loc->locinfo->lconv->int_curr_symbol);
1346 swap_pointers((void**)&locinfo->lconv->currency_symbol,
1347 (void**)&loc->locinfo->lconv->currency_symbol);
1348 swap_pointers((void**)&locinfo->lconv->mon_decimal_point,
1349 (void**)&loc->locinfo->lconv->mon_decimal_point);
1350 swap_pointers((void**)&locinfo->lconv->mon_thousands_sep,
1351 (void**)&loc->locinfo->lconv->mon_thousands_sep);
1352 swap_pointers((void**)&locinfo->lconv->mon_grouping,
1353 (void**)&loc->locinfo->lconv->mon_grouping);
1354 swap_pointers((void**)&locinfo->lconv->positive_sign,
1355 (void**)&loc->locinfo->lconv->positive_sign);
1356 swap_pointers((void**)&locinfo->lconv->negative_sign,
1357 (void**)&loc->locinfo->lconv->negative_sign);
1358 locinfo->lconv->int_frac_digits = loc->locinfo->lconv->int_frac_digits;
1359 locinfo->lconv->frac_digits = loc->locinfo->lconv->frac_digits;
1360 locinfo->lconv->p_cs_precedes = loc->locinfo->lconv->p_cs_precedes;
1361 locinfo->lconv->p_sep_by_space = loc->locinfo->lconv->p_sep_by_space;
1362 locinfo->lconv->n_cs_precedes = loc->locinfo->lconv->n_cs_precedes;
1363 locinfo->lconv->n_sep_by_space = loc->locinfo->lconv->n_sep_by_space;
1364 locinfo->lconv->p_sign_posn = loc->locinfo->lconv->p_sign_posn;
1365 locinfo->lconv->n_sign_posn = loc->locinfo->lconv->n_sign_posn;
1366
1367 if(category != MSVCRT_LC_ALL)
1368 break;
1369 /* fall through */
1370 case MSVCRT_LC_NUMERIC:
1371 locinfo->lc_handle[MSVCRT_LC_NUMERIC] =
1373 swap_pointers((void**)&locinfo->lc_category[MSVCRT_LC_NUMERIC].locale,
1374 (void**)&loc->locinfo->lc_category[MSVCRT_LC_NUMERIC].locale);
1375 swap_pointers((void**)&locinfo->lc_category[MSVCRT_LC_NUMERIC].refcount,
1376 (void**)&loc->locinfo->lc_category[MSVCRT_LC_NUMERIC].refcount);
1377
1378 swap_pointers((void**)&locinfo->lconv->decimal_point,
1379 (void**)&loc->locinfo->lconv->decimal_point);
1380 swap_pointers((void**)&locinfo->lconv->thousands_sep,
1381 (void**)&loc->locinfo->lconv->thousands_sep);
1382 swap_pointers((void**)&locinfo->lconv->grouping,
1383 (void**)&loc->locinfo->lconv->grouping);
1384
1385 if(category != MSVCRT_LC_ALL)
1386 break;
1387 /* fall through */
1388 case MSVCRT_LC_TIME:
1389 locinfo->lc_handle[MSVCRT_LC_TIME] =
1391 swap_pointers((void**)&locinfo->lc_category[MSVCRT_LC_TIME].locale,
1392 (void**)&loc->locinfo->lc_category[MSVCRT_LC_TIME].locale);
1393 swap_pointers((void**)&locinfo->lc_category[MSVCRT_LC_TIME].refcount,
1394 (void**)&loc->locinfo->lc_category[MSVCRT_LC_TIME].refcount);
1395 swap_pointers((void**)&locinfo->lc_time_curr,
1396 (void**)&loc->locinfo->lc_time_curr);
1397
1398 if(category != MSVCRT_LC_ALL)
1399 break;
1400 }
1401
1404
1405 if(locinfo == MSVCRT_locale->locinfo) {
1406 int i;
1407
1408 __lc_codepage = locinfo->lc_codepage;
1409 MSVCRT___lc_collate_cp = locinfo->lc_collate_cp;
1410 __mb_cur_max = locinfo->mb_cur_max;
1411 _pctype = locinfo->pctype;
1412 for(i=LC_MIN; i<=LC_MAX; i++)
1413 MSVCRT___lc_handle[i] = MSVCRT_locale->locinfo->lc_handle[i];
1414 }
1415
1416 if(category == MSVCRT_LC_ALL)
1417 return construct_lc_all(locinfo);
1418
1420 return locinfo->lc_category[category].locale;
1421}
#define WARN(fmt,...)
Definition: precomp.h:61
#define _pctype
Definition: wctype.h:43
#define _Analysis_assume_(expr)
Definition: ms_sal.h:2901
static char * construct_lc_all(MSVCRT_pthreadlocinfo locinfo)
Definition: locale.c:374
static void swap_pointers(void **p1, void **p2)
Definition: locale.c:345
MSVCRT_ulong lc_handle[6]
Definition: msvcrt.h:115

◆ swap_pointers()

static void swap_pointers ( void **  p1,
void **  p2 
)
inlinestatic

Definition at line 345 of file locale.c.

345 {
346 void *hlp;
347
348 hlp = *p1;
349 *p1 = *p2;
350 *p2 = hlp;
351}

Referenced by setlocale().

◆ update_threadlocinfo_category()

static BOOL update_threadlocinfo_category ( LCID  lcid,
unsigned short  cp,
MSVCRT__locale_t  loc,
int  category 
)
static

Definition at line 289 of file locale.c.

291{
292 char buf[256], *p;
293 int len;
294
296 p = buf;
297
298 loc->locinfo->lc_id[category].wLanguage = 0;
299 while(*p) {
300 loc->locinfo->lc_id[category].wLanguage *= 16;
301
302 if(*p <= '9')
303 loc->locinfo->lc_id[category].wLanguage += *p-'0';
304 else
305 loc->locinfo->lc_id[category].wLanguage += *p-'a'+10;
306
307 p++;
308 }
309
312 }
313
315
316 loc->locinfo->lc_handle[category] = lcid;
317
318 len = 0;
321 buf[len-1] = '_';
324 buf[len-1] = '.';
325 sprintf(buf+len, "%u", cp);
326 len += strlen(buf+len)+1;
327
329 loc->locinfo->lc_category[category].refcount = MSVCRT_malloc(sizeof(int));
330 if(!loc->locinfo->lc_category[category].locale
331 || !loc->locinfo->lc_category[category].refcount) {
333 MSVCRT_free(loc->locinfo->lc_category[category].refcount);
334 loc->locinfo->lc_category[category].locale = NULL;
335 loc->locinfo->lc_category[category].refcount = NULL;
336 return TRUE;
337 }
338 memcpy(loc->locinfo->lc_category[category].locale, buf, len);
339 *loc->locinfo->lc_category[category].refcount = 1;
340
341 return FALSE;
342}
unsigned short wCountry
Definition: msvcrt.h:107
unsigned short wLanguage
Definition: msvcrt.h:106

Referenced by MSVCRT__create_locale().

Variable Documentation

◆ __lc_codepage

unsigned int __lc_codepage = 0

Definition at line 34 of file locale.c.

Referenced by ___lc_codepage_func(), __init_global_locale(), setlocale(), and Test___lc_codepage().

◆ __mb_cur_max

int __mb_cur_max = 1

Definition at line 37 of file locale.c.

Referenced by __init_global_locale(), and setlocale().

◆ __setlc_active

unsigned int __setlc_active
extern

Definition at line 16 of file environ.c.

Referenced by ___setlc_active_func(), and Test___setlc_active().

◆ __unguarded_readlc_active

unsigned int __unguarded_readlc_active
extern

◆ _country_synonyms

const char* const _country_synonyms[]
static

Definition at line 50 of file locale.c.

Referenced by remap_synonym().

◆ _mbctype

unsigned char _mbctype[257] = { 0 }

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER within this package.

Definition at line 40 of file locale.c.

Referenced by _ismbbkpunct(), _setmbcp_l(), and Test__mbctype().

◆ charmax

unsigned char charmax = CHAR_MAX
static

Definition at line 38 of file locale.c.

Referenced by __lconv_init().

◆ global_locale

◆ MSVCRT___lc_collate_cp

int MSVCRT___lc_collate_cp = 0

Definition at line 35 of file locale.c.

Referenced by __init_global_locale(), and setlocale().

◆ MSVCRT___lc_handle

LCID MSVCRT___lc_handle[LC_MAX - LC_MIN+1] = { 0 }

Definition at line 36 of file locale.c.

Referenced by ___lc_handle_func(), __init_global_locale(), and setlocale().