diff options
author | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2010-02-15 11:54:21 +0000 |
---|---|---|
committer | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2010-02-15 11:54:21 +0000 |
commit | 91ce7eb52919ade33fe838a109e20e99bfe38adb (patch) | |
tree | 70c860cc37ab9208466a5a77b14d595ebe6c7080 /src | |
parent | 6e5cfb6535fa6fddad1df9f313afab6e45a97d19 (diff) | |
download | hercules-91ce7eb52919ade33fe838a109e20e99bfe38adb.tar.gz hercules-91ce7eb52919ade33fe838a109e20e99bfe38adb.tar.bz2 hercules-91ce7eb52919ade33fe838a109e20e99bfe38adb.tar.xz hercules-91ce7eb52919ade33fe838a109e20e99bfe38adb.zip |
Added visual studio equivalent of libc's strtoull() - name redefine for newer VS versions, custom implementation for VS6 (I hope it works).
This should fix the compilation error from r14242 (bugreport:4059).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14245 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r-- | src/common/cbasetypes.h | 3 | ||||
-rw-r--r-- | src/common/strlib.c | 39 | ||||
-rw-r--r-- | src/common/strlib.h | 4 |
3 files changed, 46 insertions, 0 deletions
diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 5582ca26d..b377d6ef0 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -234,6 +234,9 @@ typedef int32 intptr; #define strncmpi strncasecmp #define strnicmp strncasecmp #endif +#if defined(_MSC_VER) && _MSC_VER > 1200 +#define strtoull _strtoui64 +#endif // keyword replacement in windows #ifdef _WIN32 diff --git a/src/common/strlib.c b/src/common/strlib.c index c1d26622a..c388f949a 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -9,6 +9,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <errno.h> @@ -251,6 +252,44 @@ size_t strnlen (const char* string, size_t maxlen) } #endif +#if defined(WIN32) && defined(_MSC_VER) && _MSC_VER <= 1200 +unsigned long long strtoull(const char* str, char** endptr, int base) +{ + unsigned long long result; + int count; + int n; + + if( base == 0 ) + { + if( str[0] == '0' && (str[1] == 'x' || str[1] == 'X') ) + base = 16; + else + if( str[0] == '0' ) + base = 8; + } + + if( base == 10 ) + count = sscanf(str, "%I64u%n", &result, &n); + else + if( base == 16 ) + count = sscanf(str, "%I64x%n", &result, &n); + else + count = 0; // fail + + if( count < 1 ) + { + errno = EINVAL; + result = 0; + n = 0; + } + + if( endptr ) + *endptr = (char*)str + n; + + return result; +} +#endif + //---------------------------------------------------- // E-mail check: return 0 (not correct) or 1 (valid). //---------------------------------------------------- diff --git a/src/common/strlib.h b/src/common/strlib.h index 42034e4c1..29af06015 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -28,6 +28,10 @@ char* _strtok_r(char* s1, const char* s2, char** lasts); size_t strnlen (const char* string, size_t maxlen); #endif +#if defined(WIN32) && defined(_MSC_VER) && _MSC_VER <= 1200 +unsigned long long strtoull(const char* str, char** endptr, int base); +#endif + int e_mail_check(char* email); int config_switch(const char* str); |