summaryrefslogtreecommitdiffstats
path: root/Source/cmStringAlgorithms.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-09-20 19:17:16 (GMT)
committerBrad King <brad.king@kitware.com>2022-09-20 19:17:16 (GMT)
commit22280bce616d0291827c109cd361de3fd4965e29 (patch)
tree97829920132f02dad0a2c92d40b5cceda421d2e7 /Source/cmStringAlgorithms.cxx
parent5d80d7cb6a76e92ac5b0fa5352cdda64415124b7 (diff)
parent8fc822e13a8bf8695e475655f647d5d69f99c414 (diff)
downloadCMake-22280bce616d0291827c109cd361de3fd4965e29.zip
CMake-22280bce616d0291827c109cd361de3fd4965e29.tar.gz
CMake-22280bce616d0291827c109cd361de3fd4965e29.tar.bz2
Merge branch 'parse-large-int' into release-3.23
Merge-request: !7698
Diffstat (limited to 'Source/cmStringAlgorithms.cxx')
-rw-r--r--Source/cmStringAlgorithms.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx
index 1bb6808..f73c854 100644
--- a/Source/cmStringAlgorithms.cxx
+++ b/Source/cmStringAlgorithms.cxx
@@ -250,6 +250,38 @@ bool cmStrToULong(std::string const& str, unsigned long* value)
return cmStrToULong(str.c_str(), value);
}
+bool cmStrToLongLong(const char* str, long long* value)
+{
+ errno = 0;
+ char* endp;
+ *value = strtoll(str, &endp, 10);
+ return (*endp == '\0') && (endp != str) && (errno == 0);
+}
+
+bool cmStrToLongLong(std::string const& str, long long* value)
+{
+ return cmStrToLongLong(str.c_str(), value);
+}
+
+bool cmStrToULongLong(const char* str, unsigned long long* value)
+{
+ errno = 0;
+ char* endp;
+ while (cmIsSpace(*str)) {
+ ++str;
+ }
+ if (*str == '-') {
+ return false;
+ }
+ *value = strtoull(str, &endp, 10);
+ return (*endp == '\0') && (endp != str) && (errno == 0);
+}
+
+bool cmStrToULongLong(std::string const& str, unsigned long long* value)
+{
+ return cmStrToULongLong(str.c_str(), value);
+}
+
template <typename Range>
std::size_t getJoinedLength(Range const& rng, cm::string_view separator)
{