File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed
Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ typedef std::function<std::string()> TDeusConsoleFuncToString;
7575typedef std::function<void *()> TDeusConsoleFuncRead;
7676typedef std::function<void (void *)> TDeusConsoleFuncVoid;
7777typedef std::function<void (char *)> TDeusConsoleFuncWriteChar;
78- typedef std::unordered_map<const char *, const char * > DeusConsoleHelpTable;
78+ typedef std::unordered_map<std::string, std::string > DeusConsoleHelpTable;
7979
8080// Wrapper for console variables and their flags/methods
8181struct DeusConsoleVariable {
@@ -196,7 +196,7 @@ class IDeusConsoleManager {
196196 }
197197
198198 // Returns a reference to the help table itself, useful for iterating over potential cmds
199- std::unordered_map<std::string, std::string> & getHelpTable () {
199+ DeusConsoleHelpTable & getHelpTable () {
200200 return this ->helpTable ;
201201 }
202202
Original file line number Diff line number Diff line change @@ -88,13 +88,15 @@ inline void processCommand(char* cmd) {
8888 }
8989}
9090
91- // Compare strings by n
92- inline static int compareStrs (const char * s1, const char * s2, int n) {
91+ // Compare two strings (case-insensitive) up to n characters
92+ inline static int compareStrs (const std::string& s1, const std::string& s2, int n) {
9393 int d = 0 ;
94- while (n > 0 && (d = tolower (*s2) - tolower (*s1)) == 0 && *s1) {
95- s1++;
96- s2++;
97- n--;
94+ int i = 0 ;
95+ while (i < n && (
96+ d = std::tolower (static_cast <unsigned char >(s2[i])) -
97+ std::tolower (static_cast <unsigned char >(s1[i]))
98+ ) == 0 && i < static_cast <int >(s1.size ())) {
99+ ++i;
98100 }
99101 return d;
100102}
You can’t perform that action at this time.
0 commit comments