crtexewin.c in non-UNICODE mode parses Windows command line string. This
string is stored in the ACP. There is no CRT function which guarantees that
is working in ACP and is checking if the character is a lead byte.

CRT function isleadbyte() uses codepage from CRT's current locale which may
differs from ACP.

CRT function _ismbblead() uses codepage set by the CRT function _setmbcp()
which also may differs from ACP (but by default should be ACP).

So when parsing Windows command line arguments, use the WinAPI function
IsDBCSLeadByte() which always works according to ACP and hence should be
the right one for this purpose.
---
 mingw-w64-crt/crt/crtexewin.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/mingw-w64-crt/crt/crtexewin.c b/mingw-w64-crt/crt/crtexewin.c
index af860f3e76da..52d12bd12029 100644
--- a/mingw-w64-crt/crt/crtexewin.c
+++ b/mingw-w64-crt/crt/crtexewin.c
@@ -7,10 +7,6 @@
 #include <tchar.h>
 #include <corecrt_startup.h>
 
-#ifndef _UNICODE
-#include <mbctype.h>
-#endif
-
 #define SPACECHAR _T(' ')
 #define DQUOTECHAR _T('\"')
 
@@ -40,7 +36,7 @@ int _tmain (int      __UNUSED_PARAM(argc),
           if (*lpCmdLine == DQUOTECHAR)
             inDoubleQuote = !inDoubleQuote;
 #ifndef _UNICODE
-          if (_ismbblead (*lpCmdLine))
+          if (IsDBCSLeadByte (*lpCmdLine))
             {
               if (lpCmdLine[1])
                 ++lpCmdLine;
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to