mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 18:52:22 +00:00
Tests for hextoi, hextoi64, atobool
const hextoi / hextoi64 / atobool. null check for each. tests for each.
This commit is contained in:
+12
-3
@@ -193,7 +193,10 @@ uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const cha
|
||||
return *strlen;
|
||||
}
|
||||
|
||||
uint32 hextoi(char* num) {
|
||||
uint32 hextoi(const char* num) {
|
||||
if (num == nullptr)
|
||||
return 0;
|
||||
|
||||
int len = strlen(num);
|
||||
if (len < 3)
|
||||
return 0;
|
||||
@@ -217,7 +220,10 @@ uint32 hextoi(char* num) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint64 hextoi64(char* num) {
|
||||
uint64 hextoi64(const char* num) {
|
||||
if (num == nullptr)
|
||||
return 0;
|
||||
|
||||
int len = strlen(num);
|
||||
if (len < 3)
|
||||
return 0;
|
||||
@@ -241,7 +247,10 @@ uint64 hextoi64(char* num) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool atobool(char* iBool) {
|
||||
bool atobool(const char* iBool) {
|
||||
|
||||
if (iBool == nullptr)
|
||||
return false;
|
||||
if (!strcasecmp(iBool, "true"))
|
||||
return true;
|
||||
if (!strcasecmp(iBool, "false"))
|
||||
|
||||
+3
-3
@@ -33,9 +33,9 @@ void MakeLowerString(const char *source, char *target);
|
||||
int MakeAnyLenString(char** ret, const char* format, ...);
|
||||
uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...);
|
||||
|
||||
uint32 hextoi(char* num);
|
||||
uint64 hextoi64(char* num);
|
||||
bool atobool(char* iBool);
|
||||
uint32 hextoi(const char* num);
|
||||
uint64 hextoi64(const char* num);
|
||||
bool atobool(const char* iBool);
|
||||
|
||||
char* strn0cpy(char* dest, const char* source, uint32 size);
|
||||
// return value =true if entire string(source) fit, false if it was truncated
|
||||
|
||||
Reference in New Issue
Block a user