[PATCH 3/3] chcp: Add a help string

Hugh McMaster hugh.mcmaster at outlook.com
Tue Nov 23 06:41:40 CST 2021


Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
 programs/chcp.com/chcp.rc    |  4 ++++
 programs/chcp.com/main.c     | 12 ++++++++++--
 programs/chcp.com/resource.h |  1 +
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/programs/chcp.com/chcp.rc b/programs/chcp.com/chcp.rc
index 04d90d05942..705eb32c751 100644
--- a/programs/chcp.com/chcp.rc
+++ b/programs/chcp.com/chcp.rc
@@ -26,4 +26,8 @@ STRINGTABLE
 {
     STRING_ACTIVE_CODE_PAGE, "Active code page: %1!u!\n"
     STRING_INVALID_CODE_PAGE, "Invalid code page\n"
+    STRING_USAGE, "CHCP [number]\n\n\
+\  Sets or displays the active console code page.\n\n\
+\  number   The console code page to activate.\n\n\
+\  Type CHCP without a number to display the active console code page.\n\n"
 }
diff --git a/programs/chcp.com/main.c b/programs/chcp.com/main.c
index cc64e044b06..31ddba4c137 100644
--- a/programs/chcp.com/main.c
+++ b/programs/chcp.com/main.c
@@ -99,8 +99,16 @@ int __cdecl wmain(int argc, WCHAR *argv[])
     }
     else if (argc == 2)
     {
-        int codepage = _wtoi(argv[1]);
-        int success = SetConsoleCP(codepage) && SetConsoleOutputCP(codepage);
+        int codepage, success;
+
+        if (!lstrcmpW(argv[1], L"/?"))
+        {
+            output_message(STRING_USAGE);
+            return 0;
+        }
+
+        codepage = _wtoi(argv[1]);
+        success = SetConsoleCP(codepage) && SetConsoleOutputCP(codepage);
 
         if (success)
             output_message(STRING_ACTIVE_CODE_PAGE, codepage);
diff --git a/programs/chcp.com/resource.h b/programs/chcp.com/resource.h
index 200cbb11d18..5318b3c2e01 100644
--- a/programs/chcp.com/resource.h
+++ b/programs/chcp.com/resource.h
@@ -22,3 +22,4 @@
 
 #define STRING_ACTIVE_CODE_PAGE   100
 #define STRING_INVALID_CODE_PAGE  101
+#define STRING_USAGE              102
-- 
2.34.0




More information about the wine-devel mailing list