summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorRuslan Baratov <ruslan_baratov@yahoo.com>2014-12-05 14:18:11 (GMT)
committerBrad King <brad.king@kitware.com>2014-12-05 17:59:37 (GMT)
commit97841dad2ba5a79acb0b22db9a01ae45f7b2e80b (patch)
treea549030bf27c8d94e42fbbd35e723ff56206c07b /Source/cmSystemTools.cxx
parent356f7cf4457271ee85a71face453ea9579f05da3 (diff)
downloadCMake-97841dad2ba5a79acb0b22db9a01ae45f7b2e80b.zip
CMake-97841dad2ba5a79acb0b22db9a01ae45f7b2e80b.tar.gz
CMake-97841dad2ba5a79acb0b22db9a01ae45f7b2e80b.tar.bz2
file: Use 'long' to represent the parsed LOCK TIMEOUT value
Convert the StringToInt helper into a StringToLong helper with a 'long' result type. This will make the helper more useful to other callers that want to use strtol. While at it, also check errno after calling strtol in case the conversion fails with a range error.
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx7
1 files changed, 4 insertions, 3 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 9852dd6..c83dc2a 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -2925,9 +2925,10 @@ std::vector<std::string> cmSystemTools::tokenize(const std::string& str,
}
//----------------------------------------------------------------------------
-bool cmSystemTools::StringToInt(const char* str, int* value)
+bool cmSystemTools::StringToLong(const char* str, long* value)
{
+ errno = 0;
char *endp;
- *value = static_cast<int>(strtol(str, &endp, 10));
- return (*endp == '\0') && (endp != str);
+ *value = strtol(str, &endp, 10);
+ return (*endp == '\0') && (endp != str) && (errno == 0);
}