[PATCH v2] msvcrt: Support .OCP locale string.

Paul Gofman pgofman at codeweavers.com
Thu Sep 17 08:45:32 CDT 2020


Used by Marvel's Avengers.

Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
---
v2:
    - refine patch name;
    - handle in MSVCRT_locale_to_LCID();
    - remove redundant 'if' in test.

 dlls/msvcrt/locale.c       | 17 +++++++++++++++++
 dlls/msvcrt/tests/locale.c |  7 +++++++
 2 files changed, 24 insertions(+)

diff --git a/dlls/msvcrt/locale.c b/dlls/msvcrt/locale.c
index 9a10ceabc4e..5654c941e0b 100644
--- a/dlls/msvcrt/locale.c
+++ b/dlls/msvcrt/locale.c
@@ -308,6 +308,23 @@ LCID MSVCRT_locale_to_LCID(const char *locale, unsigned short *codepage, BOOL *s
         return data->cached_lcid;
     }
 
+    if (!strcmp(locale, ".OCP")) {
+        lcid = GetUserDefaultLCID();
+
+        if (codepage)
+        {
+            DWORD value;
+
+            GetLocaleInfoA(lcid, LOCALE_IDEFAULTCODEPAGE | LOCALE_RETURN_NUMBER,
+                    (char *)&value, sizeof(value));
+            *codepage = value;
+        }
+        if (sname)
+            *sname = FALSE;
+
+        return lcid;
+    }
+
     memset(&search, 0, sizeof(locale_search_t));
 
     cp = strchr(locale, '.');
diff --git a/dlls/msvcrt/tests/locale.c b/dlls/msvcrt/tests/locale.c
index 08abac00bed..a385d3e25c4 100644
--- a/dlls/msvcrt/tests/locale.c
+++ b/dlls/msvcrt/tests/locale.c
@@ -45,6 +45,7 @@ static void test_setlocale(void)
         "LC_MONETARY=Greek_Greece.1253;LC_NUMERIC=Polish_Poland.1250;LC_TIME=C";
 
     char *ret, buf[100];
+    char *ptr;
 
     ret = setlocale(20, "C");
     ok(ret == NULL, "ret = %s\n", ret);
@@ -612,6 +613,12 @@ static void test_setlocale(void)
         ok(!strcmp(ret, buf), "ret = %s, expected %s\n", ret, buf);
     }
 
+    ret = setlocale(LC_ALL, ".OCP");
+    ok(ret != NULL, "ret == NULL\n");
+    ptr = strchr(ret, '.');
+    GetLocaleInfoA(GetUserDefaultLCID(), LOCALE_IDEFAULTCODEPAGE, buf, sizeof(buf));
+    ok(ptr && !strcmp(ptr + 1, buf), "ret %s, buf %s.\n", ret, buf);
+
     ret = setlocale(LC_ALL, "English_United States.UTF8");
     ok(ret == NULL, "ret != NULL\n");
 
-- 
2.26.2




More information about the wine-devel mailing list