| 200 | // This function assumes that the first character of s is a digit. |
| 201 | template <typename Char> |
| 202 | int parse_nonnegative_int(const Char *&s) { |
| 203 | assert('0' <= *s && *s <= '9'); |
| 204 | unsigned value = 0; |
| 205 | do { |
| 206 | unsigned new_value = value * 10 + (*s++ - '0'); |
| 207 | // Check if value wrapped around. |
| 208 | if (new_value < value) { |
| 209 | value = UINT_MAX; |
| 210 | break; |
| 211 | } |
| 212 | value = new_value; |
| 213 | } while ('0' <= *s && *s <= '9'); |
| 214 | if (value > INT_MAX) |
| 215 | FMT_THROW(fmt::FormatError("number is too big")); |
| 216 | return value; |
| 217 | } |
| 218 | |
| 219 | inline void require_numeric_argument(const Arg &arg, char spec) { |
| 220 | if (arg.type > Arg::LAST_NUMERIC_TYPE) { |
no test coverage detected