| 108 | } |
| 109 | |
| 110 | bool LegacyParseUInt64(const std::string& str, uint64_t* out) |
| 111 | { |
| 112 | if (!LegacyParsePrechecks(str)) |
| 113 | return false; |
| 114 | if (str.size() >= 1 && str[0] == '-') // Reject negative values, unfortunately strtoull accepts these by default if they fit in the range |
| 115 | return false; |
| 116 | char* endp = nullptr; |
| 117 | errno = 0; // strtoull will not set errno if valid |
| 118 | unsigned long long int n = strtoull(str.c_str(), &endp, 10); |
| 119 | if (out) *out = (uint64_t)n; |
| 120 | // Note that strtoull returns a *unsigned long long int*, so even if it doesn't report an over/underflow |
| 121 | // we still have to check that the returned value is within the range of an *uint64_t*. |
| 122 | return endp && *endp == 0 && !errno && |
| 123 | n <= std::numeric_limits<uint64_t>::max(); |
| 124 | } |
| 125 | |
| 126 | // For backwards compatibility checking. |
| 127 | int64_t atoi64_legacy(const std::string& str) |
no test coverage detected