https://git.reactos.org/?p=reactos.git;a=commitdiff;h=53bd132cec8ca86339382…
commit 53bd132cec8ca86339382678779b6f423db3eba1
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Wed May 26 01:19:10 2021 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Wed May 26 01:42:12 2021 +0200
[CMD] Reset the current thread UI language at startup, and when updating the local
code page cache.
CORE-17601
---
base/shell/cmd/cmd.c | 32 ++++++++++++++++++++++----------
base/shell/cmd/start.c | 20 +++++++++++++-------
2 files changed, 35 insertions(+), 17 deletions(-)
diff --git a/base/shell/cmd/cmd.c b/base/shell/cmd/cmd.c
index 05ca5969d43..99070ff24f9 100644
--- a/base/shell/cmd/cmd.c
+++ b/base/shell/cmd/cmd.c
@@ -506,14 +506,14 @@ Execute(LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND
*Cmd)
dwExitCode = 1;
}
- /* Restore our default console mode */
+ /* Restore the default console mode */
SetConsoleMode(ConStreamGetOSHandle(StdIn),
ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT);
SetConsoleMode(ConStreamGetOSHandle(StdOut),
ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT);
}
- /* Update our local codepage cache */
+ /* Update the local code page cache */
{
UINT uNewInputCodePage = GetConsoleCP();
UINT uNewOutputCodePage = GetConsoleOutputCP();
@@ -521,15 +521,21 @@ Execute(LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND
*Cmd)
if ((InputCodePage != uNewInputCodePage) ||
(OutputCodePage != uNewOutputCodePage))
{
+ InputCodePage = uNewInputCodePage;
+ OutputCodePage = uNewOutputCodePage;
+
+ /* Reset the current thread UI language */
+ if (IsConsoleHandle(ConStreamGetOSHandle(StdOut)) ||
+ IsConsoleHandle(ConStreamGetOSHandle(StdErr)))
+ {
+ ConSetThreadUILanguage(0);
+ }
+ /* Update the streams cached code page */
+ ConStdStreamsSetCacheCodePage(InputCodePage, OutputCodePage);
+
/* Update the locale as well */
InitLocale();
}
-
- InputCodePage = uNewInputCodePage;
- OutputCodePage = uNewOutputCodePage;
-
- /* Update the streams codepage cache as well */
- ConStdStreamsSetCacheCodePage(InputCodePage, OutputCodePage);
}
/* Restore the original console title */
@@ -2178,7 +2184,7 @@ Initialize(VOID)
/* Add ctrl break handler */
AddBreakHandler();
- /* Set our default console mode */
+ /* Set the default console mode */
hOut = ConStreamGetOSHandle(StdOut);
hIn = ConStreamGetOSHandle(StdIn);
SetConsoleMode(hOut, 0); // Reinitialize the console output mode
@@ -2287,7 +2293,7 @@ Initialize(VOID)
ConSetScreenColor(ConStreamGetOSHandle(StdOut), wDefColor, TRUE);
#endif
- /* Reset the output Standard Streams translation modes and codepage caches */
+ /* Reset the output Standard Streams translation modes and code page caches */
// ConStreamSetMode(StdIn , OutputStreamMode, InputCodePage );
ConStreamSetMode(StdOut, OutputStreamMode, OutputCodePage);
ConStreamSetMode(StdErr, OutputStreamMode, OutputCodePage);
@@ -2374,6 +2380,12 @@ int _tmain(int argc, const TCHAR *argv[])
ConStreamInit(StdIn , GetStdHandle(STD_INPUT_HANDLE) , /*OutputStreamMode*/ AnsiText,
InputCodePage);
ConStreamInit(StdOut, GetStdHandle(STD_OUTPUT_HANDLE), OutputStreamMode,
OutputCodePage);
ConStreamInit(StdErr, GetStdHandle(STD_ERROR_HANDLE) , OutputStreamMode,
OutputCodePage);
+ /* Reset the current thread UI language */
+ if (IsConsoleHandle(ConStreamGetOSHandle(StdOut)) ||
+ IsConsoleHandle(ConStreamGetOSHandle(StdErr)))
+ {
+ ConSetThreadUILanguage(0);
+ }
CMD_ModuleHandle = GetModuleHandle(NULL);
diff --git a/base/shell/cmd/start.c b/base/shell/cmd/start.c
index 901502e43df..aec8aa8c853 100644
--- a/base/shell/cmd/start.c
+++ b/base/shell/cmd/start.c
@@ -305,7 +305,7 @@ INT cmd_start (LPTSTR Rest)
}
CloseHandle (prci.hProcess);
- /* Update our local codepage cache */
+ /* Update the local code page cache */
{
UINT uNewInputCodePage = GetConsoleCP();
UINT uNewOutputCodePage = GetConsoleOutputCP();
@@ -313,15 +313,21 @@ INT cmd_start (LPTSTR Rest)
if ((InputCodePage != uNewInputCodePage) ||
(OutputCodePage != uNewOutputCodePage))
{
+ InputCodePage = uNewInputCodePage;
+ OutputCodePage = uNewOutputCodePage;
+
+ /* Reset the current thread UI language */
+ if (IsConsoleHandle(ConStreamGetOSHandle(StdOut)) ||
+ IsConsoleHandle(ConStreamGetOSHandle(StdErr)))
+ {
+ ConSetThreadUILanguage(0);
+ }
+ /* Update the streams cached code page */
+ ConStdStreamsSetCacheCodePage(InputCodePage, OutputCodePage);
+
/* Update the locale as well */
InitLocale();
}
-
- InputCodePage = uNewInputCodePage;
- OutputCodePage = uNewOutputCodePage;
-
- /* Update the streams codepage cache as well */
- ConStdStreamsSetCacheCodePage(InputCodePage, OutputCodePage);
}
}
else