Commit fd2ddf8f authored by Victor Chiletto's avatar Victor Chiletto Committed by Alexandre Julliard

msvcrt: Remove uses of wcsncpy from locale_to_sname.

parent 46596db7
......@@ -329,8 +329,10 @@ find_best_locale_proc( WCHAR *name, DWORD locale_flags, LPARAM lParam )
return CONTINUE_LOOKING;
}
/* 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)
/* Internal: Find the sname for a locale specification.
* 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();
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;
if (sname_match)
*sname_match = data->cached_sname_match;
wcsncpy(sname, data->cached_sname, sname_size);
wcscpy(sname, data->cached_sname);
return TRUE;
}
......@@ -350,7 +352,7 @@ BOOL locale_to_sname(const char *locale, unsigned short *codepage, BOOL *sname_m
region = strchr(locale, '_');
if(!locale[0] || (cp == locale && !region)) {
GetUserDefaultLocaleName(sname, sname_size);
GetUserDefaultLocaleName(sname, LOCALE_NAME_MAX_LENGTH);
} else {
char search_language_buf[MAX_ELEM_LEN] = { 0 }, search_country_buf[MAX_ELEM_LEN] = { 0 };
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))
{
search.match_flags = FOUND_SNAME;
wcsncpy(sname, search.search_language, sname_size);
wcscpy(sname, search.search_language);
}
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))
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;
......@@ -1333,9 +1335,9 @@ static pthreadlocinfo create_locinfo(int category,
if(p) {
memcpy(buf, locale, p-locale);
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 {
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)))
......@@ -1352,7 +1354,7 @@ static pthreadlocinfo create_locinfo(int category,
locale = p+1;
}
} 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)
return NULL;
......
......@@ -254,7 +254,7 @@ threadmbcinfo* create_mbcinfo(int cp, LCID lcid, threadmbcinfo *old_mbcinfo)
if(lcid == -1) {
WCHAR wbuf[LOCALE_NAME_MAX_LENGTH];
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 {
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;
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 __lc_time_data cloc_time_data DECLSPEC_HIDDEN;
extern unsigned int MSVCRT___lc_codepage;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment