https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f79c02bd8a9797ab18078…
commit f79c02bd8a9797ab1807884862928ffb817d2d54
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Thu Jan 27 21:36:16 2022 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Fri Feb 4 21:35:15 2022 +0100
[CONSRV] Introduce a CON_SET_OUTPUT_CP() macro to simplify setting the console's
output CP + associated changes. Simplify ConDrvSetConsoleCP() as well.
---
win32ss/user/winsrv/consrv/condrv/console.c | 24 +++++++++++-------------
win32ss/user/winsrv/consrv/include/conio.h | 6 ++++++
win32ss/user/winsrv/consrv/settings.c | 4 ++--
3 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/win32ss/user/winsrv/consrv/condrv/console.c
b/win32ss/user/winsrv/consrv/condrv/console.c
index fae7beb7de3..74d2229b4db 100644
--- a/win32ss/user/winsrv/consrv/condrv/console.c
+++ b/win32ss/user/winsrv/consrv/condrv/console.c
@@ -116,9 +116,10 @@ ConDrvInitConsole(
/* Set-up the code page */
if (IsValidCodePage(ConsoleInfo->CodePage))
- Console->InputCodePage = Console->OutputCodePage =
ConsoleInfo->CodePage;
-
- Console->IsCJK = IsCJKCodePage(Console->OutputCodePage);
+ {
+ CON_SET_OUTPUT_CP(Console, ConsoleInfo->CodePage);
+ Console->InputCodePage = ConsoleInfo->CodePage;
+ }
/* Initialize a new text-mode screen buffer with default settings */
ScreenBufferInfo.ScreenBufferSize = ConsoleInfo->ScreenBufferSize;
@@ -424,27 +425,24 @@ ConDrvSetConsoleCP(IN PCONSOLE Console,
IN UINT CodePage,
IN BOOLEAN OutputCP)
{
- BOOL Success = TRUE;
-
if (Console == NULL || !IsValidCodePage(CodePage))
return STATUS_INVALID_PARAMETER;
if (OutputCP)
{
/* Request the terminal to change its code page support */
- Success = TermSetCodePage(Console, CodePage);
- if (Success)
- {
- Console->OutputCodePage = CodePage;
- Console->IsCJK = IsCJKCodePage(CodePage);
- }
+ if (!TermSetCodePage(Console, CodePage))
+ return STATUS_UNSUCCESSFUL;
+
+ /* All is fine, actually set the output code page */
+ CON_SET_OUTPUT_CP(Console, CodePage);
+ return STATUS_SUCCESS;
}
else
{
Console->InputCodePage = CodePage;
+ return STATUS_SUCCESS;
}
-
- return (Success ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL);
}
/* EOF */
diff --git a/win32ss/user/winsrv/consrv/include/conio.h
b/win32ss/user/winsrv/consrv/include/conio.h
index ead041e51df..0c8ae92631c 100644
--- a/win32ss/user/winsrv/consrv/include/conio.h
+++ b/win32ss/user/winsrv/consrv/include/conio.h
@@ -320,6 +320,12 @@ ConDrvUnpause(PCONSOLE Console);
#define GetConsoleInputBufferMode(Console) \
(Console)->InputBuffer.Mode
+#define CON_SET_OUTPUT_CP(Console, CodePage)\
+do { \
+ (Console)->OutputCodePage = (CodePage); \
+ (Console)->IsCJK = IsCJKCodePage((Console)->OutputCodePage); \
+} while (0)
+
/* conoutput.c */
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y);
diff --git a/win32ss/user/winsrv/consrv/settings.c
b/win32ss/user/winsrv/consrv/settings.c
index 22cccc2d81c..4594d6e8e6d 100644
--- a/win32ss/user/winsrv/consrv/settings.c
+++ b/win32ss/user/winsrv/consrv/settings.c
@@ -68,8 +68,8 @@ ConSrvApplyUserSettings(
// ConDrvSetConsoleCP(Console, ConsoleInfo->CodePage, FALSE); // Input
if (TermSetCodePage(Console, ConsoleInfo->CodePage))
{
- Console->InputCodePage = Console->OutputCodePage =
ConsoleInfo->CodePage;
- Console->IsCJK = IsCJKCodePage(Console->OutputCodePage);
+ CON_SET_OUTPUT_CP(Console, ConsoleInfo->CodePage);
+ Console->InputCodePage = ConsoleInfo->CodePage;
}
}