cmSystemTools: Add StringToULong helper

Convert a string to an unsigned integer and reject any extra input.
This commit is contained in:
Brad King 2015-06-24 09:41:58 -04:00
parent dffc307c81
commit 8bf5a80b96
2 changed files with 10 additions and 0 deletions

View File

@ -2955,3 +2955,12 @@ bool cmSystemTools::StringToLong(const char* str, long* value)
*value = strtol(str, &endp, 10);
return (*endp == '\0') && (endp != str) && (errno == 0);
}
//----------------------------------------------------------------------------
bool cmSystemTools::StringToULong(const char* str, unsigned long* value)
{
errno = 0;
char *endp;
*value = strtoul(str, &endp, 10);
return (*endp == '\0') && (endp != str) && (errno == 0);
}

View File

@ -469,6 +469,7 @@ public:
/** Convert string to long. Expected that the whole string is an integer */
static bool StringToLong(const char* str, long* value);
static bool StringToULong(const char* str, unsigned long* value);
#ifdef _WIN32
struct WindowsFileRetry