mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-02 22:13:40 +00:00
msvcrt: Remove uses of wcsncpy from locale_to_sname.
This commit is contained in:
parent
46596db7ed
commit
fd2ddf8f2a
|
@ -329,8 +329,10 @@ find_best_locale_proc( WCHAR *name, DWORD locale_flags, LPARAM lParam )
|
||||||
return CONTINUE_LOOKING;
|
return CONTINUE_LOOKING;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Internal: Find the sname for a locale specification */
|
/* Internal: Find the sname for a locale specification.
|
||||||
BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_match, WCHAR *sname, int sname_size)
|
* sname must be at least LOCALE_NAME_MAX_LENGTH characters long
|
||||||
|
*/
|
||||||
|
BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_match, WCHAR *sname)
|
||||||
{
|
{
|
||||||
thread_data_t *data = msvcrt_get_thread_data();
|
thread_data_t *data = msvcrt_get_thread_data();
|
||||||
const char *cp, *region;
|
const char *cp, *region;
|
||||||
|
@ -342,7 +344,7 @@ BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_m
|
||||||
*codepage = data->cached_cp;
|
*codepage = data->cached_cp;
|
||||||
if (sname_match)
|
if (sname_match)
|
||||||
*sname_match = data->cached_sname_match;
|
*sname_match = data->cached_sname_match;
|
||||||
wcsncpy(sname, data->cached_sname, sname_size);
|
wcscpy(sname, data->cached_sname);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +352,7 @@ BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_m
|
||||||
region = strchr(locale, '_');
|
region = strchr(locale, '_');
|
||||||
|
|
||||||
if(!locale[0] || (cp == locale && !region)) {
|
if(!locale[0] || (cp == locale && !region)) {
|
||||||
GetUserDefaultLocaleName(sname, sname_size);
|
GetUserDefaultLocaleName(sname, LOCALE_NAME_MAX_LENGTH);
|
||||||
} else {
|
} else {
|
||||||
char search_language_buf[MAX_ELEM_LEN] = { 0 }, search_country_buf[MAX_ELEM_LEN] = { 0 };
|
char search_language_buf[MAX_ELEM_LEN] = { 0 }, search_country_buf[MAX_ELEM_LEN] = { 0 };
|
||||||
locale_search_t search;
|
locale_search_t search;
|
||||||
|
@ -388,7 +390,7 @@ BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_m
|
||||||
if (search.allow_sname && IsValidLocaleName(search.search_language))
|
if (search.allow_sname && IsValidLocaleName(search.search_language))
|
||||||
{
|
{
|
||||||
search.match_flags = FOUND_SNAME;
|
search.match_flags = FOUND_SNAME;
|
||||||
wcsncpy(sname, search.search_language, sname_size);
|
wcscpy(sname, search.search_language);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -404,7 +406,7 @@ BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_m
|
||||||
if (search.search_country[0] && !(search.match_flags & FOUND_COUNTRY))
|
if (search.search_country[0] && !(search.match_flags & FOUND_COUNTRY))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
wcsncpy(sname, search.found_lang_sname, sname_size);
|
wcscpy(sname, search.found_lang_sname);
|
||||||
}
|
}
|
||||||
|
|
||||||
is_sname = !remapped && (search.match_flags & FOUND_SNAME) != 0;
|
is_sname = !remapped && (search.match_flags & FOUND_SNAME) != 0;
|
||||||
|
@ -1333,9 +1335,9 @@ static pthreadlocinfo create_locinfo(int category,
|
||||||
if(p) {
|
if(p) {
|
||||||
memcpy(buf, locale, p-locale);
|
memcpy(buf, locale, p-locale);
|
||||||
buf[p-locale] = '\0';
|
buf[p-locale] = '\0';
|
||||||
locale_found = locale_to_sname(buf, &cp[i], &sname_match, wbuf, LOCALE_NAME_MAX_LENGTH);
|
locale_found = locale_to_sname(buf, &cp[i], &sname_match, wbuf);
|
||||||
} else {
|
} else {
|
||||||
locale_found = locale_to_sname(locale, &cp[i], &sname_match, wbuf, LOCALE_NAME_MAX_LENGTH);
|
locale_found = locale_to_sname(locale, &cp[i], &sname_match, wbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!locale_found || !(locale_sname[i] = wcsdup(wbuf)))
|
if(!locale_found || !(locale_sname[i] = wcsdup(wbuf)))
|
||||||
|
@ -1352,7 +1354,7 @@ static pthreadlocinfo create_locinfo(int category,
|
||||||
locale = p+1;
|
locale = p+1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BOOL locale_found = locale_to_sname(locale, &cp[0], &sname_match, wbuf, LOCALE_NAME_MAX_LENGTH);
|
BOOL locale_found = locale_to_sname(locale, &cp[0], &sname_match, wbuf);
|
||||||
|
|
||||||
if(!locale_found)
|
if(!locale_found)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -254,7 +254,7 @@ threadmbcinfo* create_mbcinfo(int cp, LCID lcid, threadmbcinfo *old_mbcinfo)
|
||||||
if(lcid == -1) {
|
if(lcid == -1) {
|
||||||
WCHAR wbuf[LOCALE_NAME_MAX_LENGTH];
|
WCHAR wbuf[LOCALE_NAME_MAX_LENGTH];
|
||||||
sprintf(bufA, ".%d", newcp);
|
sprintf(bufA, ".%d", newcp);
|
||||||
mbcinfo->mblcid = locale_to_sname(bufA, NULL, NULL, wbuf, LOCALE_NAME_MAX_LENGTH) ? LocaleNameToLCID(wbuf, LOCALE_ALLOW_NEUTRAL_NAMES) : -1;
|
mbcinfo->mblcid = locale_to_sname(bufA, NULL, NULL, wbuf) ? LocaleNameToLCID(wbuf, LOCALE_ALLOW_NEUTRAL_NAMES) : -1;
|
||||||
} else {
|
} else {
|
||||||
mbcinfo->mblcid = lcid;
|
mbcinfo->mblcid = lcid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,7 +186,7 @@ typedef struct __thread_data thread_data_t;
|
||||||
|
|
||||||
extern thread_data_t *CDECL msvcrt_get_thread_data(void) DECLSPEC_HIDDEN;
|
extern thread_data_t *CDECL msvcrt_get_thread_data(void) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
BOOL locale_to_sname(const char*, unsigned short*, BOOL*, WCHAR*, int) DECLSPEC_HIDDEN;
|
BOOL locale_to_sname(const char*, unsigned short*, BOOL*, WCHAR*) DECLSPEC_HIDDEN;
|
||||||
extern _locale_t MSVCRT_locale DECLSPEC_HIDDEN;
|
extern _locale_t MSVCRT_locale DECLSPEC_HIDDEN;
|
||||||
extern __lc_time_data cloc_time_data DECLSPEC_HIDDEN;
|
extern __lc_time_data cloc_time_data DECLSPEC_HIDDEN;
|
||||||
extern unsigned int MSVCRT___lc_codepage;
|
extern unsigned int MSVCRT___lc_codepage;
|
||||||
|
|
Loading…
Reference in a new issue