| 304 | |
| 305 | |
| 306 | void decode_json_obj(long& val, JSONObj *obj) |
| 307 | { |
| 308 | string s = obj->get_data(); |
| 309 | const char *start = s.c_str(); |
| 310 | char *p; |
| 311 | |
| 312 | errno = 0; |
| 313 | val = strtol(start, &p, 10); |
| 314 | |
| 315 | /* Check for various possible errors */ |
| 316 | |
| 317 | if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN)) || |
| 318 | (errno != 0 && val == 0)) { |
| 319 | throw JSONDecoder::err("failed to parse number"); |
| 320 | } |
| 321 | |
| 322 | if (p == start) { |
| 323 | throw JSONDecoder::err("failed to parse number"); |
| 324 | } |
| 325 | |
| 326 | while (*p != '\0') { |
| 327 | if (!isspace(*p)) { |
| 328 | throw JSONDecoder::err("failed to parse number"); |
| 329 | } |
| 330 | p++; |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | void decode_json_obj(unsigned long& val, JSONObj *obj) |
| 335 | { |
nothing calls this directly
no test coverage detected