cmSystemTools: Add StringToULong helper
Convert a string to an unsigned integer and reject any extra input.
This commit is contained in:
parent
dffc307c81
commit
8bf5a80b96
|
@ -2955,3 +2955,12 @@ bool cmSystemTools::StringToLong(const char* str, long* value)
|
||||||
*value = strtol(str, &endp, 10);
|
*value = strtol(str, &endp, 10);
|
||||||
return (*endp == '\0') && (endp != str) && (errno == 0);
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -469,6 +469,7 @@ public:
|
||||||
|
|
||||||
/** Convert string to long. Expected that the whole string is an integer */
|
/** Convert string to long. Expected that the whole string is an integer */
|
||||||
static bool StringToLong(const char* str, long* value);
|
static bool StringToLong(const char* str, long* value);
|
||||||
|
static bool StringToULong(const char* str, unsigned long* value);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
struct WindowsFileRetry
|
struct WindowsFileRetry
|
||||||
|
|
Loading…
Reference in New Issue