Commit 8bf5a80b authored by Brad King's avatar Brad King
Browse files

cmSystemTools: Add StringToULong helper

Convert a string to an unsigned integer and reject any extra input.
parent dffc307c
......@@ -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);
}
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment