| 64 | } |
| 65 | |
| 66 | bool LegacyParseInt64(const std::string& str, int64_t* out) |
| 67 | { |
| 68 | if (!LegacyParsePrechecks(str)) |
| 69 | return false; |
| 70 | char* endp = nullptr; |
| 71 | errno = 0; // strtoll will not set errno if valid |
| 72 | long long int n = strtoll(str.c_str(), &endp, 10); |
| 73 | if (out) *out = (int64_t)n; |
| 74 | // Note that strtoll returns a *long long int*, so even if strtol doesn't report an over/underflow |
| 75 | // we still have to check that the returned value is within the range of an *int64_t*. |
| 76 | return endp && *endp == 0 && !errno && |
| 77 | n >= std::numeric_limits<int64_t>::min() && |
| 78 | n <= std::numeric_limits<int64_t>::max(); |
| 79 | } |
| 80 | |
| 81 | bool LegacyParseUInt32(const std::string& str, uint32_t* out) |
| 82 | { |
no test coverage detected