[PATCH 0/2] MR1090: Draft: msvcrt: implement missing _mbctolower_l CRT function to fix ChessBase 14 crash
_mbctolower_l - converts multibyte uppercase character to lowercase character, by using specified locale that's passed in. More information about these methods are available at: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/mbctolower... More information about application crash: https://bugs.winehq.org/show_bug.cgi?id=45273 -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1090
From: Bartosz Kosiorek <gang65(a)poczta.onet.pl> _mbctolower_l - converts multibyte uppercase character to lowercase character, by using specified locale that's passed in. More information about these methods are available at: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/mbctolower... More information about application crash: https://bugs.winehq.org/show_bug.cgi?id=45273 --- dlls/msvcr100/msvcr100.spec | 2 +- dlls/msvcr110/msvcr110.spec | 2 +- dlls/msvcr120/msvcr120.spec | 2 +- dlls/msvcr80/msvcr80.spec | 2 +- dlls/msvcr90/msvcr90.spec | 2 +- dlls/msvcrt/mbcs.c | 18 ++++++++++++++---- dlls/ucrtbase/ucrtbase.spec | 2 +- 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec index c0bbbc5b86d..648092da5a4 100644 --- a/dlls/msvcr100/msvcr100.spec +++ b/dlls/msvcr100/msvcr100.spec @@ -1088,7 +1088,7 @@ @ cdecl _mbctokata(long) @ stub _mbctokata_l @ cdecl _mbctolower(long) -@ stub _mbctolower_l +@ cdecl _mbctolower_l(long ptr) @ cdecl _mbctombb(long) @ stub _mbctombb_l @ cdecl _mbctoupper(long) diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec index a272ae98a1c..03d96e91d86 100644 --- a/dlls/msvcr110/msvcr110.spec +++ b/dlls/msvcr110/msvcr110.spec @@ -1445,7 +1445,7 @@ @ cdecl _mbctokata(long) @ stub _mbctokata_l @ cdecl _mbctolower(long) -@ stub _mbctolower_l +@ cdecl _mbctolower_l(long ptr) @ cdecl _mbctombb(long) @ stub _mbctombb_l @ cdecl _mbctoupper(long) diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec index d16316e7e05..8eb007f3945 100644 --- a/dlls/msvcr120/msvcr120.spec +++ b/dlls/msvcr120/msvcr120.spec @@ -1456,7 +1456,7 @@ @ cdecl _mbctokata(long) @ stub _mbctokata_l @ cdecl _mbctolower(long) -@ stub _mbctolower_l +@ cdecl _mbctolower_l(long ptr) @ cdecl _mbctombb(long) @ stub _mbctombb_l @ cdecl _mbctoupper(long) diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index 371d17ecc21..b0c81808198 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -760,7 +760,7 @@ @ cdecl _mbctokata(long) @ stub _mbctokata_l @ cdecl _mbctolower(long) -@ stub _mbctolower_l +@ cdecl _mbctolower_l(long ptr) @ cdecl _mbctombb(long) @ stub _mbctombb_l @ cdecl _mbctoupper(long) diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index dc9d4ae097b..f0b6e43b33c 100644 --- a/dlls/msvcr90/msvcr90.spec +++ b/dlls/msvcr90/msvcr90.spec @@ -738,7 +738,7 @@ @ cdecl _mbctokata(long) @ stub _mbctokata_l @ cdecl _mbctolower(long) -@ stub _mbctolower_l +@ cdecl _mbctolower_l(long ptr) @ cdecl _mbctombb(long) @ stub _mbctombb_l @ cdecl _mbctoupper(long) diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index dc9abca1b44..5d373a21eb0 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -25,6 +25,7 @@ #include <stdio.h> #include <limits.h> +#include <locale.h> #include <mbctype.h> #include <mbstring.h> @@ -447,16 +448,25 @@ unsigned int CDECL _mbsnextc(const unsigned char* str) } /********************************************************************* - * _mbctolower(MSVCRT.@) + * _mbctolower_l(MSVCRT.@) + * converts multibyte uppercase character to lowercase character, by using specified locale that's passed in. */ -unsigned int CDECL _mbctolower(unsigned int c) +unsigned int CDECL _mbctolower_l(unsigned int c, _locale_t locale) { - if (_ismbblead(c)) + if (_ismbblead_l(c, locale)) { FIXME("Handle MBC chars\n"); return c; } - return _tolower_l(c, NULL); /* ASCII CP or SB char */ + return _tolower_l(c, locale); /* ASCII CP or SB char */ +} + +/********************************************************************* + * _mbctolower(MSVCRT.@) + */ +unsigned int CDECL _mbctolower(unsigned int c) +{ + return _mbctolower_l(c, NULL); } /********************************************************************* diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec index a4acf724d2f..f85309a7b42 100644 --- a/dlls/ucrtbase/ucrtbase.spec +++ b/dlls/ucrtbase/ucrtbase.spec @@ -603,7 +603,7 @@ @ cdecl _mbctokata(long) @ stub _mbctokata_l @ cdecl _mbctolower(long) -@ stub _mbctolower_l +@ cdecl _mbctolower_l(long ptr) @ cdecl _mbctombb(long) @ stub _mbctombb_l @ cdecl _mbctoupper(long) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1090
From: Bartosz Kosiorek <gang65(a)poczta.onet.pl> _mbctoupper_l - converts multibyte uppercase character to lowercase character, by using specified locale that's passed in. More information about these methods are available at: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/mbctolower... More information about application crash: https://bugs.winehq.org/show_bug.cgi?id=45273 --- dlls/msvcr100/msvcr100.spec | 2 +- dlls/msvcr110/msvcr110.spec | 2 +- dlls/msvcr120/msvcr120.spec | 2 +- dlls/msvcr80/msvcr80.spec | 2 +- dlls/msvcr90/msvcr90.spec | 2 +- dlls/msvcrt/mbcs.c | 18 ++++++++++++++---- dlls/ucrtbase/ucrtbase.spec | 2 +- 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec index 648092da5a4..b3fd1af1ecb 100644 --- a/dlls/msvcr100/msvcr100.spec +++ b/dlls/msvcr100/msvcr100.spec @@ -1092,7 +1092,7 @@ @ cdecl _mbctombb(long) @ stub _mbctombb_l @ cdecl _mbctoupper(long) -@ stub _mbctoupper_l +@ cdecl _mbctoupper_l(long ptr) @ extern _mbctype MSVCRT_mbctype @ stub _mblen_l @ cdecl _mbsbtype(str long) diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec index 03d96e91d86..28e5e047090 100644 --- a/dlls/msvcr110/msvcr110.spec +++ b/dlls/msvcr110/msvcr110.spec @@ -1449,7 +1449,7 @@ @ cdecl _mbctombb(long) @ stub _mbctombb_l @ cdecl _mbctoupper(long) -@ stub _mbctoupper_l +@ cdecl _mbctoupper_l(long ptr) @ extern _mbctype MSVCRT_mbctype @ stub _mblen_l @ cdecl _mbsbtype(str long) diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec index 8eb007f3945..ae4874a7116 100644 --- a/dlls/msvcr120/msvcr120.spec +++ b/dlls/msvcr120/msvcr120.spec @@ -1460,7 +1460,7 @@ @ cdecl _mbctombb(long) @ stub _mbctombb_l @ cdecl _mbctoupper(long) -@ stub _mbctoupper_l +@ cdecl _mbctoupper_l(long ptr) @ extern _mbctype MSVCRT_mbctype @ stub _mblen_l @ cdecl _mbsbtype(str long) diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index b0c81808198..7b484d8be26 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -764,7 +764,7 @@ @ cdecl _mbctombb(long) @ stub _mbctombb_l @ cdecl _mbctoupper(long) -@ stub _mbctoupper_l +@ cdecl _mbctoupper_l(long ptr) @ extern _mbctype MSVCRT_mbctype @ stub _mblen_l @ cdecl _mbsbtype(str long) diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index f0b6e43b33c..ab1ef139f9a 100644 --- a/dlls/msvcr90/msvcr90.spec +++ b/dlls/msvcr90/msvcr90.spec @@ -742,7 +742,7 @@ @ cdecl _mbctombb(long) @ stub _mbctombb_l @ cdecl _mbctoupper(long) -@ stub _mbctoupper_l +@ cdecl _mbctoupper_l(long ptr) @ extern _mbctype MSVCRT_mbctype @ stub _mblen_l @ cdecl _mbsbtype(str long) diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index 5d373a21eb0..a47de1f2f42 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -470,16 +470,26 @@ unsigned int CDECL _mbctolower(unsigned int c) } /********************************************************************* - * _mbctoupper(MSVCRT.@) + * _mbctoupper_l(MSVCRT.@) + * converts multibyte lowercase character to uppercase character, + * by using specified locale that's passed in. */ -unsigned int CDECL _mbctoupper(unsigned int c) +unsigned int CDECL _mbctoupper_l(unsigned int c, _locale_t locale) { - if (_ismbblead(c)) + if (_ismbblead_l(c, locale)) { FIXME("Handle MBC chars\n"); return c; } - return _toupper_l(c, NULL); /* ASCII CP or SB char */ + return _toupper_l(c, locale); /* ASCII CP or SB char */ +} + +/********************************************************************* + * _mbctoupper(MSVCRT.@) + */ +unsigned int CDECL _mbctoupper(unsigned int c) +{ + return _mbctoupper_l(c, NULL); } /********************************************************************* diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec index f85309a7b42..c803799f4cd 100644 --- a/dlls/ucrtbase/ucrtbase.spec +++ b/dlls/ucrtbase/ucrtbase.spec @@ -607,7 +607,7 @@ @ cdecl _mbctombb(long) @ stub _mbctombb_l @ cdecl _mbctoupper(long) -@ stub _mbctoupper_l +@ cdecl _mbctoupper_l(long ptr) @ stub _mblen_l @ cdecl _mbsbtype(str long) @ stub _mbsbtype_l -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1090
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details: The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=125089 Your paranoid android. === debian11 (32 bit report) === ddraw: ddraw7.c:15663: Test failed: Expected unsynchronised map for flags 0x1000. ddraw7.c:15663: Test failed: Expected unsynchronised map for flags 0x3000. === debian11 (build log) === Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 24748. Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 24748. Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 24748.
Piotr Caban (@piotr) commented about dlls/msvcrt/mbcs.c:
#include <stdio.h> #include <limits.h> +#include <locale.h>
The patch is marked as draft so I'm not sure if you consider it ready. It generally looks good for me. The CI test job sometimes fails - you can ignore the failure since it's not related to your patch. Please change the commit message to something like: ``` msvcrt: Add _mbctolower_l partial implementation. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45273 ``` locale.h include should not be needed. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1090#note_11159
Piotr Caban (@piotr) commented about dlls/msvcrt/mbcs.c:
}
/********************************************************************* - * _mbctolower(MSVCRT.@) + * _mbctolower_l(MSVCRT.@) + * converts multibyte uppercase character to lowercase character, by using specified locale that's passed in. The comment is not very useful, it's documented what _mbctolower_l function is doing, please remove it.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/1090#note_11160
participants (4)
-
Bartosz Kosiorek -
Bartosz Kosiorek (@gang65) -
Marvin -
Piotr Caban (@piotr)