diff options
author | Ruslan Baratov <ruslan_baratov@yahoo.com> | 2014-11-25 22:45:26 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-12-03 14:47:26 (GMT) |
commit | 05d6531c7a8ecfad513a0e76b44b273b70fa919b (patch) | |
tree | 82f4563add948600202a9f7d4dfeba81bfb5a51e /Source/cmSystemTools.cxx | |
parent | 3350e4d209b6a7ff758ca371af4d62844a66ab36 (diff) | |
download | CMake-05d6531c7a8ecfad513a0e76b44b273b70fa919b.zip CMake-05d6531c7a8ecfad513a0e76b44b273b70fa919b.tar.gz CMake-05d6531c7a8ecfad513a0e76b44b273b70fa919b.tar.bz2 |
cmSystemTools: Add StringToInt helper
Convert a string to a signed integer and reject any extra input.
Co-Author: Rolf Eike Beer <eike@sf-mail.de>
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index baac7b8..9852dd6 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2923,3 +2923,11 @@ std::vector<std::string> cmSystemTools::tokenize(const std::string& str, } return tokens; } + +//---------------------------------------------------------------------------- +bool cmSystemTools::StringToInt(const char* str, int* value) +{ + char *endp; + *value = static_cast<int>(strtol(str, &endp, 10)); + return (*endp == '\0') && (endp != str); +} |