Fixed build with latest version of MSYS2/Mingw-w64.

This commit is contained in:
LoRd_MuldeR 2023-03-26 15:52:00 +02:00
parent 60916768ac
commit 548787d7b2
2 changed files with 28 additions and 8 deletions

View File

@ -65,7 +65,7 @@ for %%m in (32,64) do (
echo Build %%m-Bit echo Build %%m-Bit
echo ======================================================================== echo ========================================================================
echo. echo.
call "%MSYS2_DIR%\msys2_shell.cmd" -mingw%%m -no-start -defterm -where "%~dp0" -c "make -B -j8" call "%MSYS2_DIR%\msys2_shell.cmd" -mingw%%m -no-start -defterm -where "%~dp0" -c "make -B"
if not "!ERRORLEVEL!"=="0" goto:BuildHasFailed if not "!ERRORLEVEL!"=="0" goto:BuildHasFailed
echo. echo.
) )

View File

@ -22,6 +22,7 @@
#include <errno.h> #include <errno.h>
#include <direct.h> #include <direct.h>
#include <fcntl.h> #include <fcntl.h>
#include <mbctype.h>
// Win32 API // Win32 API
#include <Windows.h> #include <Windows.h>
@ -78,6 +79,8 @@ static const DWORD SPLASH_SCREEN_TIMEOUT = 30000U;
/* String routines */ /* String routines */
/* ======================================================================== */ /* ======================================================================== */
static const wchar_t SPACE_CHAR = L'\x20';
#define XSTR(S) STR(S) #define XSTR(S) STR(S)
#define STR(S) #S #define STR(S) #S
@ -145,13 +148,11 @@ static wchar_t *wcsndup (const wchar_t *const str, const size_t n)
return result; return result;
} }
static const wchar_t *skip_leading_spaces(const wchar_t *const str) static const wchar_t *skip_leading_spaces(const wchar_t *str)
{ {
if (NOT_EMPTY(str)) if (NOT_EMPTY(str))
{ {
const wchar_t *result; for (; (*str) && (*str <= SPACE_CHAR); ++str);
for (result = str; (*result) && iswspace(*result); ++result);
return result;
} }
return str; return str;
} }
@ -1104,6 +1105,25 @@ static const wchar_t *get_java_full_path(const wchar_t *const jre_base_path, con
/* Command-line */ /* Command-line */
/* ======================================================================== */ /* ======================================================================== */
static const wchar_t *get_commandline_args(const wchar_t *cmd_line)
{
BOOL double_quote = FALSE;
if (NOT_EMPTY(cmd_line))
{
cmd_line = skip_leading_spaces(cmd_line);
for (; (*cmd_line) && ((*cmd_line > SPACE_CHAR) || double_quote); ++cmd_line)
{
if (*cmd_line == L'"') double_quote = (!double_quote);
if (_ismbblead(*cmd_line) && cmd_line[1U]) ++cmd_line;
}
return skip_leading_spaces(cmd_line);
}
else
{
return L"";
}
}
static wchar_t *encode_commandline_args(const int argc, const LPWSTR *const argv) static wchar_t *encode_commandline_args(const int argc, const LPWSTR *const argv)
{ {
if (!(argv && (argc > 0))) if (!(argv && (argc > 0)))
@ -1784,8 +1804,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
return launch5j_main(hInstance, pCmdLine); return launch5j_main(hInstance, pCmdLine);
} }
#else #else
extern HINSTANCE __mingw_winmain_hInstance; extern IMAGE_DOS_HEADER __ImageBase;
extern LPWSTR __mingw_winmain_lpCmdLine; extern LPWSTR _wcmdln;
int wmain(int argc, wchar_t **argv, wchar_t **envp) int wmain(int argc, wchar_t **argv, wchar_t **envp)
{ {
#ifdef NDEBUG #ifdef NDEBUG
@ -1793,6 +1813,6 @@ int wmain(int argc, wchar_t **argv, wchar_t **envp)
SetUnhandledExceptionFilter(unhandeled_exception); SetUnhandledExceptionFilter(unhandeled_exception);
#endif #endif
_setmode(_fileno(stderr), _O_U8TEXT); _setmode(_fileno(stderr), _O_U8TEXT);
return launch5j_main(__mingw_winmain_hInstance, __mingw_winmain_lpCmdLine); return launch5j_main((HINSTANCE) &__ImageBase, get_commandline_args(_wcmdln));
} }
#endif #endif