diff options
| author | Brad King <brad.king@kitware.com> | 2022-09-20 19:17:16 (GMT) |
|---|---|---|
| committer | Brad King <brad.king@kitware.com> | 2022-09-20 19:17:16 (GMT) |
| commit | 22280bce616d0291827c109cd361de3fd4965e29 (patch) | |
| tree | 97829920132f02dad0a2c92d40b5cceda421d2e7 /Source/cmStringAlgorithms.cxx | |
| parent | 5d80d7cb6a76e92ac5b0fa5352cdda64415124b7 (diff) | |
| parent | 8fc822e13a8bf8695e475655f647d5d69f99c414 (diff) | |
| download | CMake-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.cxx | 32 |
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) { |
