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

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jan 5 13:36:05 CST 2007


Module: wine
Branch: master
Commit: f70fb8ec4c19739b579b9f3d5c47aaed1777f29e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f70fb8ec4c19739b579b9f3d5c47aaed1777f29e

Author: Dmitry Timoshkov <dmitry at codeweavers.com>
Date:   Fri Jan  5 14:25:39 2007 +0800

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;




More information about the wine-cvs mailing list