mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8337506: Disable "best-fit" mapping on Windows command line
Reviewed-by: alanb
This commit is contained in:
parent
3f8b3e5527
commit
ff634a9670
2 changed files with 103 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -110,7 +110,25 @@ main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
}
|
||||
JLI_CmdToArgs(GetCommandLine());
|
||||
|
||||
// Obtain the command line in UTF-16, then convert it to ANSI code page
|
||||
// without the "best-fit" option
|
||||
LPWSTR wcCmdline = GetCommandLineW();
|
||||
int mbSize = WideCharToMultiByte(CP_ACP,
|
||||
WC_NO_BEST_FIT_CHARS | WC_COMPOSITECHECK | WC_DEFAULTCHAR,
|
||||
wcCmdline, -1, NULL, 0, NULL, NULL);
|
||||
// If the call to WideCharToMultiByte() fails, it returns 0, which
|
||||
// will then make the following JLI_MemAlloc() to issue exit(1)
|
||||
LPSTR mbCmdline = JLI_MemAlloc(mbSize);
|
||||
if (WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS | WC_COMPOSITECHECK | WC_DEFAULTCHAR,
|
||||
wcCmdline, -1, mbCmdline, mbSize, NULL, NULL) == 0) {
|
||||
perror("command line encoding conversion failure");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
JLI_CmdToArgs(mbCmdline);
|
||||
JLI_MemFree(mbCmdline);
|
||||
|
||||
margc = JLI_GetStdArgc();
|
||||
// add one more to mark the end
|
||||
margv = (char **)JLI_MemAlloc((margc + 1) * (sizeof(char *)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue