Commit 249cc1e8 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

msvcrt: _Gettnames() should respect user overrides.

parent 3fbed4c4
...@@ -1493,6 +1493,8 @@ static MSVCRT_pthreadlocinfo create_locinfo(int category, ...@@ -1493,6 +1493,8 @@ static MSVCRT_pthreadlocinfo create_locinfo(int category,
locinfo->lc_handle[MSVCRT_LC_TIME] = old_locinfo->lc_handle[MSVCRT_LC_TIME]; locinfo->lc_handle[MSVCRT_LC_TIME] = old_locinfo->lc_handle[MSVCRT_LC_TIME];
locinfo->lc_id[MSVCRT_LC_TIME].wCodePage = old_locinfo->lc_id[MSVCRT_LC_TIME].wCodePage; locinfo->lc_id[MSVCRT_LC_TIME].wCodePage = old_locinfo->lc_id[MSVCRT_LC_TIME].wCodePage;
} else { } else {
DWORD flags = lcid[MSVCRT_LC_TIME] ? 0 : LOCALE_NOUSEROVERRIDE;
if(lcid[MSVCRT_LC_TIME] && (category==MSVCRT_LC_ALL || category==MSVCRT_LC_TIME)) { if(lcid[MSVCRT_LC_TIME] && (category==MSVCRT_LC_ALL || category==MSVCRT_LC_TIME)) {
if(update_threadlocinfo_category(lcid[MSVCRT_LC_TIME], if(update_threadlocinfo_category(lcid[MSVCRT_LC_TIME],
cp[MSVCRT_LC_TIME], locinfo, MSVCRT_LC_TIME)) { cp[MSVCRT_LC_TIME], locinfo, MSVCRT_LC_TIME)) {
...@@ -1515,16 +1517,14 @@ static MSVCRT_pthreadlocinfo create_locinfo(int category, ...@@ -1515,16 +1517,14 @@ static MSVCRT_pthreadlocinfo create_locinfo(int category,
}else if(time_data[i]==LOCALE_SLONGDATE && !lcid[MSVCRT_LC_TIME]) { }else if(time_data[i]==LOCALE_SLONGDATE && !lcid[MSVCRT_LC_TIME]) {
size += sizeof(cloc_long_date) + sizeof(cloc_long_dateW); size += sizeof(cloc_long_date) + sizeof(cloc_long_dateW);
}else { }else {
ret = GetLocaleInfoA(lcid_tmp, time_data[i] ret = GetLocaleInfoA(lcid_tmp, time_data[i]|flags, NULL, 0);
|LOCALE_NOUSEROVERRIDE, NULL, 0);
if(!ret) { if(!ret) {
free_locinfo(locinfo); free_locinfo(locinfo);
return NULL; return NULL;
} }
size += ret; size += ret;
ret = GetLocaleInfoW(lcid_tmp, time_data[i] ret = GetLocaleInfoW(lcid_tmp, time_data[i]|flags, NULL, 0);
|LOCALE_NOUSEROVERRIDE, NULL, 0);
if(!ret) { if(!ret) {
free_locinfo(locinfo); free_locinfo(locinfo);
return NULL; return NULL;
...@@ -1555,7 +1555,7 @@ static MSVCRT_pthreadlocinfo create_locinfo(int category, ...@@ -1555,7 +1555,7 @@ static MSVCRT_pthreadlocinfo create_locinfo(int category,
memcpy(&locinfo->lc_time_curr->data[ret], cloc_time, sizeof(cloc_time)); memcpy(&locinfo->lc_time_curr->data[ret], cloc_time, sizeof(cloc_time));
ret += sizeof(cloc_time); ret += sizeof(cloc_time);
}else { }else {
ret += GetLocaleInfoA(lcid_tmp, time_data[i]|LOCALE_NOUSEROVERRIDE, ret += GetLocaleInfoA(lcid_tmp, time_data[i]|flags,
&locinfo->lc_time_curr->data[ret], size-ret); &locinfo->lc_time_curr->data[ret], size-ret);
} }
} }
...@@ -1571,7 +1571,7 @@ static MSVCRT_pthreadlocinfo create_locinfo(int category, ...@@ -1571,7 +1571,7 @@ static MSVCRT_pthreadlocinfo create_locinfo(int category,
memcpy(&locinfo->lc_time_curr->data[ret], cloc_timeW, sizeof(cloc_timeW)); memcpy(&locinfo->lc_time_curr->data[ret], cloc_timeW, sizeof(cloc_timeW));
ret += sizeof(cloc_timeW); ret += sizeof(cloc_timeW);
}else { }else {
ret += GetLocaleInfoW(lcid_tmp, time_data[i]|LOCALE_NOUSEROVERRIDE, ret += GetLocaleInfoW(lcid_tmp, time_data[i]|flags,
(MSVCRT_wchar_t*)&locinfo->lc_time_curr->data[ret], size-ret)*sizeof(MSVCRT_wchar_t); (MSVCRT_wchar_t*)&locinfo->lc_time_curr->data[ret], size-ret)*sizeof(MSVCRT_wchar_t);
} }
} }
......
...@@ -663,6 +663,24 @@ static void test_crtGetStringTypeW(void) ...@@ -663,6 +663,24 @@ static void test_crtGetStringTypeW(void)
static void test__Gettnames(void) static void test__Gettnames(void)
{ {
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
};
struct { struct {
char *str[43]; char *str[43];
LCID lcid; LCID lcid;
...@@ -672,6 +690,7 @@ static void test__Gettnames(void) ...@@ -672,6 +690,7 @@ static void test__Gettnames(void)
} *ret; } *ret;
int size; int size;
char buf[64]; char buf[64];
int i;
if(!setlocale(LC_ALL, "english")) if(!setlocale(LC_ALL, "english"))
return; return;
...@@ -686,100 +705,27 @@ static void test__Gettnames(void) ...@@ -686,100 +705,27 @@ static void test__Gettnames(void)
else else
ok(size==0x164 || broken(size==0xb8), "structure size: %x\n", size); ok(size==0x164 || broken(size==0xb8), "structure size: %x\n", size);
ok(!strcmp(ret->str[0], "Sun"), "ret->str[0] = %s\n", ret->str[0]); for (i = 0; i < sizeof(time_data)/sizeof(time_data[0]); i++)
ok(!strcmp(ret->str[1], "Mon"), "ret->str[1] = %s\n", ret->str[1]); {
ok(!strcmp(ret->str[2], "Tue"), "ret->str[2] = %s\n", ret->str[2]); size = GetLocaleInfoA(MAKELCID(LANG_ENGLISH, SORT_DEFAULT),
ok(!strcmp(ret->str[3], "Wed"), "ret->str[3] = %s\n", ret->str[3]); time_data[i], buf, sizeof(buf));
ok(!strcmp(ret->str[4], "Thu"), "ret->str[4] = %s\n", ret->str[4]); ok(size, "GetLocaleInfo failed: %x\n", GetLastError());
ok(!strcmp(ret->str[5], "Fri"), "ret->str[5] = %s\n", ret->str[5]); ok(!strcmp(ret->str[i], buf), "ret->str[%i] = %s, expected %s\n", i, ret->str[i], buf);
ok(!strcmp(ret->str[6], "Sat"), "ret->str[6] = %s\n", ret->str[6]); }
ok(!strcmp(ret->str[7], "Sunday"), "ret->str[7] = %s\n", ret->str[7]);
ok(!strcmp(ret->str[8], "Monday"), "ret->str[8] = %s\n", ret->str[8]);
ok(!strcmp(ret->str[9], "Tuesday"), "ret->str[9] = %s\n", ret->str[9]);
ok(!strcmp(ret->str[10], "Wednesday"), "ret->str[10] = %s\n", ret->str[10]);
ok(!strcmp(ret->str[11], "Thursday"), "ret->str[11] = %s\n", ret->str[11]);
ok(!strcmp(ret->str[12], "Friday"), "ret->str[12] = %s\n", ret->str[12]);
ok(!strcmp(ret->str[13], "Saturday"), "ret->str[13] = %s\n", ret->str[13]);
ok(!strcmp(ret->str[14], "Jan"), "ret->str[14] = %s\n", ret->str[14]);
ok(!strcmp(ret->str[15], "Feb"), "ret->str[15] = %s\n", ret->str[15]);
ok(!strcmp(ret->str[16], "Mar"), "ret->str[16] = %s\n", ret->str[16]);
ok(!strcmp(ret->str[17], "Apr"), "ret->str[17] = %s\n", ret->str[17]);
ok(!strcmp(ret->str[18], "May"), "ret->str[18] = %s\n", ret->str[18]);
ok(!strcmp(ret->str[19], "Jun"), "ret->str[19] = %s\n", ret->str[19]);
ok(!strcmp(ret->str[20], "Jul"), "ret->str[20] = %s\n", ret->str[20]);
ok(!strcmp(ret->str[21], "Aug"), "ret->str[21] = %s\n", ret->str[21]);
ok(!strcmp(ret->str[22], "Sep"), "ret->str[22] = %s\n", ret->str[22]);
ok(!strcmp(ret->str[23], "Oct"), "ret->str[23] = %s\n", ret->str[23]);
ok(!strcmp(ret->str[24], "Nov"), "ret->str[24] = %s\n", ret->str[24]);
ok(!strcmp(ret->str[25], "Dec"), "ret->str[25] = %s\n", ret->str[25]);
ok(!strcmp(ret->str[26], "January"), "ret->str[26] = %s\n", ret->str[26]);
ok(!strcmp(ret->str[27], "February"), "ret->str[27] = %s\n", ret->str[27]);
ok(!strcmp(ret->str[28], "March"), "ret->str[28] = %s\n", ret->str[28]);
ok(!strcmp(ret->str[29], "April"), "ret->str[29] = %s\n", ret->str[29]);
ok(!strcmp(ret->str[30], "May"), "ret->str[30] = %s\n", ret->str[30]);
ok(!strcmp(ret->str[31], "June"), "ret->str[31] = %s\n", ret->str[31]);
ok(!strcmp(ret->str[32], "July"), "ret->str[32] = %s\n", ret->str[32]);
ok(!strcmp(ret->str[33], "August"), "ret->str[33] = %s\n", ret->str[33]);
ok(!strcmp(ret->str[34], "September"), "ret->str[34] = %s\n", ret->str[34]);
ok(!strcmp(ret->str[35], "October"), "ret->str[35] = %s\n", ret->str[35]);
ok(!strcmp(ret->str[36], "November"), "ret->str[36] = %s\n", ret->str[36]);
ok(!strcmp(ret->str[37], "December"), "ret->str[37] = %s\n", ret->str[37]);
ok(!strcmp(ret->str[38], "AM"), "ret->str[38] = %s\n", ret->str[38]);
ok(!strcmp(ret->str[39], "PM"), "ret->str[39] = %s\n", ret->str[39]);
ok(!strcmp(ret->str[40], "M/d/yyyy") || broken(!strcmp(ret->str[40], "M/d/yy"))/*NT*/,
"ret->str[40] = %s\n", ret->str[40]);
size = GetLocaleInfoA(MAKELCID(LANG_ENGLISH, SORT_DEFAULT),
LOCALE_SLONGDATE|LOCALE_NOUSEROVERRIDE, buf, sizeof(buf));
ok(size, "GetLocaleInfo failed: %x\n", GetLastError());
ok(!strcmp(ret->str[41], buf), "ret->str[41] = %s, expected %s\n", ret->str[41], buf);
free(ret); free(ret);
if(!setlocale(LC_TIME, "german")) if(!setlocale(LC_TIME, "german"))
return; return;
ret = _Gettnames(); ret = _Gettnames();
ok(!strcmp(ret->str[0], "So"), "ret->str[0] = %s\n", ret->str[0]); for (i = 0; i < sizeof(time_data)/sizeof(time_data[0]); i++)
ok(!strcmp(ret->str[1], "Mo"), "ret->str[1] = %s\n", ret->str[1]); {
ok(!strcmp(ret->str[2], "Di"), "ret->str[2] = %s\n", ret->str[2]); size = GetLocaleInfoA(MAKELCID(LANG_GERMAN, SORT_DEFAULT),
ok(!strcmp(ret->str[3], "Mi"), "ret->str[3] = %s\n", ret->str[3]); time_data[i], buf, sizeof(buf));
ok(!strcmp(ret->str[4], "Do"), "ret->str[4] = %s\n", ret->str[4]); ok(size, "GetLocaleInfo failed: %x\n", GetLastError());
ok(!strcmp(ret->str[5], "Fr"), "ret->str[5] = %s\n", ret->str[5]); ok(!strcmp(ret->str[i], buf), "ret->str[%i] = %s, expected %s\n", i, ret->str[i], buf);
ok(!strcmp(ret->str[6], "Sa"), "ret->str[6] = %s\n", ret->str[6]); }
ok(!strcmp(ret->str[7], "Sonntag"), "ret->str[7] = %s\n", ret->str[7]);
ok(!strcmp(ret->str[8], "Montag"), "ret->str[8] = %s\n", ret->str[8]);
ok(!strcmp(ret->str[9], "Dienstag"), "ret->str[9] = %s\n", ret->str[9]);
ok(!strcmp(ret->str[10], "Mittwoch"), "ret->str[10] = %s\n", ret->str[10]);
ok(!strcmp(ret->str[11], "Donnerstag"), "ret->str[11] = %s\n", ret->str[11]);
ok(!strcmp(ret->str[12], "Freitag"), "ret->str[12] = %s\n", ret->str[12]);
ok(!strcmp(ret->str[13], "Samstag"), "ret->str[13] = %s\n", ret->str[13]);
ok(!strcmp(ret->str[14], "Jan"), "ret->str[14] = %s\n", ret->str[14]);
ok(!strcmp(ret->str[15], "Feb"), "ret->str[15] = %s\n", ret->str[15]);
ok(!strcmp(ret->str[16], "Mrz"), "ret->str[16] = %s\n", ret->str[16]);
ok(!strcmp(ret->str[17], "Apr"), "ret->str[17] = %s\n", ret->str[17]);
ok(!strcmp(ret->str[18], "Mai"), "ret->str[18] = %s\n", ret->str[18]);
ok(!strcmp(ret->str[19], "Jun"), "ret->str[19] = %s\n", ret->str[19]);
ok(!strcmp(ret->str[20], "Jul"), "ret->str[20] = %s\n", ret->str[20]);
ok(!strcmp(ret->str[21], "Aug"), "ret->str[21] = %s\n", ret->str[21]);
ok(!strcmp(ret->str[22], "Sep"), "ret->str[22] = %s\n", ret->str[22]);
ok(!strcmp(ret->str[23], "Okt"), "ret->str[23] = %s\n", ret->str[23]);
ok(!strcmp(ret->str[24], "Nov"), "ret->str[24] = %s\n", ret->str[24]);
ok(!strcmp(ret->str[25], "Dez"), "ret->str[25] = %s\n", ret->str[25]);
ok(!strcmp(ret->str[26], "Januar"), "ret->str[26] = %s\n", ret->str[26]);
ok(!strcmp(ret->str[27], "Februar"), "ret->str[27] = %s\n", ret->str[27]);
ok(!strcmp(ret->str[29], "April"), "ret->str[29] = %s\n", ret->str[29]);
ok(!strcmp(ret->str[30], "Mai"), "ret->str[30] = %s\n", ret->str[30]);
ok(!strcmp(ret->str[31], "Juni"), "ret->str[31] = %s\n", ret->str[31]);
ok(!strcmp(ret->str[32], "Juli"), "ret->str[32] = %s\n", ret->str[32]);
ok(!strcmp(ret->str[33], "August"), "ret->str[33] = %s\n", ret->str[33]);
ok(!strcmp(ret->str[34], "September"), "ret->str[34] = %s\n", ret->str[34]);
ok(!strcmp(ret->str[35], "Oktober"), "ret->str[35] = %s\n", ret->str[35]);
ok(!strcmp(ret->str[36], "November"), "ret->str[36] = %s\n", ret->str[36]);
ok(!strcmp(ret->str[37], "Dezember"), "ret->str[37] = %s\n", ret->str[37]);
ok(!strcmp(ret->str[38], ""), "ret->str[38] = %s\n", ret->str[38]);
ok(!strcmp(ret->str[39], ""), "ret->str[39] = %s\n", ret->str[39]);
ok(!strcmp(ret->str[40], "dd.MM.yyyy") || broken(!strcmp(ret->str[40], "dd.MM.yy"))/*NT*/,
"ret->str[40] = %s\n", ret->str[40]);
ok(!strcmp(ret->str[41], "dddd, d. MMMM yyyy"), "ret->str[41] = %s\n", ret->str[41]);
free(ret); free(ret);
setlocale(LC_ALL, "C"); setlocale(LC_ALL, "C");
......
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