https://git.reactos.org/?p=reactos.git;a=commitdiff;h=35f499e52f20c9b04bf1f…
commit 35f499e52f20c9b04bf1ff6b622152f70b00702c
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Wed May 26 00:01:26 2021 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Wed May 26 01:42:09 2021 +0200
[CONUTILS][CMD] Add and use a helper ConStdStreamsSetCacheCodePage() macro instead of
repeatedly calling ConStreamSetCacheCodePage() on the standard streams.
---
base/shell/cmd/cmd.c | 4 +---
base/shell/cmd/start.c | 4 +---
sdk/lib/conutils/stream.h | 15 ++++++++++++++-
3 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/base/shell/cmd/cmd.c b/base/shell/cmd/cmd.c
index e92426d8cb3..05ca5969d43 100644
--- a/base/shell/cmd/cmd.c
+++ b/base/shell/cmd/cmd.c
@@ -529,9 +529,7 @@ Execute(LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd)
OutputCodePage = uNewOutputCodePage;
/* Update the streams codepage cache as well */
- ConStreamSetCacheCodePage(StdIn , InputCodePage );
- ConStreamSetCacheCodePage(StdOut, OutputCodePage);
- ConStreamSetCacheCodePage(StdErr, OutputCodePage);
+ ConStdStreamsSetCacheCodePage(InputCodePage, OutputCodePage);
}
/* Restore the original console title */
diff --git a/base/shell/cmd/start.c b/base/shell/cmd/start.c
index de07c3e0e7e..901502e43df 100644
--- a/base/shell/cmd/start.c
+++ b/base/shell/cmd/start.c
@@ -321,9 +321,7 @@ INT cmd_start (LPTSTR Rest)
OutputCodePage = uNewOutputCodePage;
/* Update the streams codepage cache as well */
- ConStreamSetCacheCodePage(StdIn , InputCodePage );
- ConStreamSetCacheCodePage(StdOut, OutputCodePage);
- ConStreamSetCacheCodePage(StdErr, OutputCodePage);
+ ConStdStreamsSetCacheCodePage(InputCodePage, OutputCodePage);
}
}
else
diff --git a/sdk/lib/conutils/stream.h b/sdk/lib/conutils/stream.h
index 17e8b0a7431..6e1dbe486d4 100644
--- a/sdk/lib/conutils/stream.h
+++ b/sdk/lib/conutils/stream.h
@@ -136,14 +136,27 @@ ConStreamSetMode(
IN UINT CacheCodePage OPTIONAL);
#ifdef USE_CRT
+
// FIXME!
#warning The ConStreamSetCacheCodePage function does not make much sense with the CRT!
+
+#define ConStdStreamsSetCacheCodePage(InputCodePage, OutputCodePage) NOTHING
+
#else
+
BOOL
ConStreamSetCacheCodePage(
IN PCON_STREAM Stream,
IN UINT CacheCodePage);
-#endif
+
+#define ConStdStreamsSetCacheCodePage(InputCodePage, OutputCodePage) \
+do { \
+ ConStreamSetCacheCodePage(StdIn , (InputCodePage )); \
+ ConStreamSetCacheCodePage(StdOut, (OutputCodePage)); \
+ ConStreamSetCacheCodePage(StdErr, (OutputCodePage)); \
+} while(0)
+
+#endif /* defined(USE_CRT) */
HANDLE
ConStreamGetOSHandle(