From f70fb8ec4c19739b579b9f3d5c47aaed1777f29e Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Fri, 5 Jan 2007 14:25:39 +0800 Subject: [PATCH] kernel32: GetTimeFormat and GetDateFormat should fail if LOCALE_NOUSEROVERRIDE is specified simultaneously with a format string. --- dlls/kernel32/lcformat.c | 4 ++-- dlls/kernel32/tests/locale.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/lcformat.c b/dlls/kernel32/lcformat.c index 068e2fc919b..5a3a332bd8a 100644 --- a/dlls/kernel32/lcformat.c +++ b/dlls/kernel32/lcformat.c @@ -329,10 +329,10 @@ BOOL NLS_IsUnicodeOnlyLcid(LCID lcid) #define IsTimeFmtChar(p) (p == 'H'||p == 'h'||p == 'm'||p == 's'||p == 't') /* Only the following flags can be given if a date/time format is specified */ -#define DATE_FORMAT_FLAGS (DATE_DATEVARSONLY|LOCALE_NOUSEROVERRIDE) +#define DATE_FORMAT_FLAGS (DATE_DATEVARSONLY) #define TIME_FORMAT_FLAGS (TIME_TIMEVARSONLY|TIME_FORCE24HOURFORMAT| \ TIME_NOMINUTESORSECONDS|TIME_NOSECONDS| \ - TIME_NOTIMEMARKER|LOCALE_NOUSEROVERRIDE) + TIME_NOTIMEMARKER) /****************************************************************************** * NLS_GetDateTimeFormatW diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c index d2158be3fa9..2efa6f879f9 100644 --- a/dlls/kernel32/tests/locale.c +++ b/dlls/kernel32/tests/locale.c @@ -183,6 +183,11 @@ static void test_GetTimeFormatA(void) ret = GetTimeFormatA(lcid, TIME_FORCE24HOURFORMAT, &curtime, input, buffer, COUNTOF(buffer)); EXPECT_VALID; EXPECT_LENA; EXPECT_EQA; + /* MSDN: LOCALE_NOUSEROVERRIDE can't be specified with a format string */ + SetLastError(0xdeadbeef); + ret = GetTimeFormatA(lcid, NUO|TIME_FORCE24HOURFORMAT, &curtime, input, buffer, COUNTOF(buffer)); + EXPECT_FLAGS; EXPECT_LEN(0); EXPECT_EQA; + STRINGSA("tt HH':'mm'@'ss", "A"); /* Insufficent buffer */ SetLastError(0xdeadbeef); ret = GetTimeFormatA(lcid, TIME_FORCE24HOURFORMAT, &curtime, input, buffer, 2); @@ -339,6 +344,12 @@ static void test_GetDateFormatA(void) ret = GetDateFormatA(lcid, 0, &curtime, input, buffer, COUNTOF(buffer)); EXPECT_VALID; EXPECT_LENA; EXPECT_EQA; + /* Same as above but with LOCALE_NOUSEROVERRIDE */ + STRINGSA("ddd',' MMM dd yy",""); /* Simple case */ + SetLastError(0xdeadbeef); + ret = GetDateFormatA(lcid, NUO, &curtime, input, buffer, COUNTOF(buffer)); + EXPECT_FLAGS; EXPECT_LEN(0); EXPECT_EQA; + STRINGSA("ddd',' MMM dd yy","Sat, May 04 02"); /* Format containing "'" */ ret = GetDateFormatA(lcid, 0, &curtime, input, buffer, COUNTOF(buffer)); EXPECT_VALID; EXPECT_LENA; EXPECT_EQA; @@ -370,12 +381,14 @@ static void test_GetDateFormatA(void) /* test for expected DATE_YEARMONTH behavior with null format */ /* NT4 returns ERROR_INVALID_FLAGS for DATE_YEARMONTH */ STRINGSA("ddd',' MMM dd ''''yy", ""); /* DATE_YEARMONTH */ + SetLastError(0xdeadbeef); ret = GetDateFormat(lcid, NUO|DATE_YEARMONTH, &curtime, input, buffer, COUNTOF(buffer)); EXPECT_FLAGS; EXPECT_LEN(0); EXPECT_EQA; /* Test that using invalid DATE_* flags results in the correct error */ /* and return values */ STRINGSA("m/d/y", ""); /* Invalid flags */ + SetLastError(0xdeadbeef); ret = GetDateFormat(lcid, DATE_YEARMONTH|DATE_SHORTDATE|DATE_LONGDATE, &curtime, input, buffer, COUNTOF(buffer)); EXPECT_FLAGS; EXPECT_LEN(0); EXPECT_EQA;