* Convert an entry into an integer. */
| 59 | * Convert an entry into an integer. |
| 60 | */ |
| 61 | static bool entryToInt(const char *entry, intptr_t *val) |
| 62 | { |
| 63 | const char *s = entry; |
| 64 | while (isspace(*s)) |
| 65 | s++; |
| 66 | bool neg = false; |
| 67 | if (s[0] == '+') |
| 68 | s++; |
| 69 | else if (s[0] == '-') |
| 70 | { |
| 71 | neg = true; |
| 72 | s++; |
| 73 | } |
| 74 | int base = (s[0] == '0' && s[1] == 'x'? 16: 10); |
| 75 | char *end = nullptr; |
| 76 | intptr_t x = (intptr_t)strtoull(s, &end, base); |
| 77 | if (end == nullptr || end == s) |
| 78 | return false; |
| 79 | while (isspace(*end)) |
| 80 | end++; |
| 81 | if (*end != '\0') |
| 82 | return false; |
| 83 | *val = (neg? -x: x); |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | /* |
| 88 | * Checked getc. |
no test coverage detected