| 26 | } |
| 27 | |
| 28 | bool parse_ptr(const std::wstring &text, byte *&ptr) { |
| 29 | auto input = trim_ws(text); |
| 30 | if (input.empty()) { |
| 31 | return false; |
| 32 | } |
| 33 | errno = 0; |
| 34 | wchar_t *end = nullptr; |
| 35 | auto value = wcstoull(input.c_str(), &end, 0); |
| 36 | if (end == input.c_str()) { |
| 37 | return false; |
| 38 | } |
| 39 | while (*end != L'\0' && iswspace(*end)) { |
| 40 | ++end; |
| 41 | } |
| 42 | if (*end != L'\0' || errno == ERANGE || value == 0) { |
| 43 | return false; |
| 44 | } |
| 45 | ptr = reinterpret_cast<byte *>(static_cast<uintptr_t>(value)); |
| 46 | return ptr != nullptr; |
| 47 | } |
| 48 | |
| 49 | bool parse_positive_int(const std::wstring &text, int &value) { |
| 50 | auto input = trim_ws(text); |
no test coverage detected