kernel32: GetTimeFormat and GetDateFormat should fail if LOCALE_NOUSEROVERRIDE is specified simultaneously with a format string

Dmitry Timoshkov dmitry at codeweavers.com
Fri Jan 5 00:25:39 CST 2007


Hello,

I investigated the reason why I had to fix the GetTimeFormat tests to pass
under XP by removing LOCALE_NOUSEROVERRIDE in some places, but not everywhere.

MSDN explicitly states in the GetTimeFormat description that if the format
string is passed then LOCALE_NOUSEROVERRIDE should not be set. The tests
confirm that, also the tests show the same behaviour for GetDateFormat although
MSDN keeps silence in that case.

Changelog:
    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 068e2fc..5a3a332 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 <internal>
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c
index d2158be..2efa6f8 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;
-- 
1.4.4.2






More information about the wine-patches mailing list