| 469 | /* Coerce V to an integer value. Return true on success, false on failure. */ |
| 470 | |
| 471 | static bool |
| 472 | toarith (VALUE *v) |
| 473 | { |
| 474 | switch (v->type) |
| 475 | { |
| 476 | case integer: |
| 477 | return true; |
| 478 | case string: |
| 479 | { |
| 480 | char *s = v->u.s; |
| 481 | |
| 482 | if (! looks_like_integer (s)) |
| 483 | return false; |
| 484 | if (mpz_init_set_str (v->u.i, s, 10) != 0) |
| 485 | error (EXPR_FAILURE, ERANGE, "%s", (s)); |
| 486 | free (s); |
| 487 | v->type = integer; |
| 488 | return true; |
| 489 | } |
| 490 | default: |
| 491 | unreachable (); |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | /* Extract a size_t value from an integer value I. |
| 496 | If the value is negative, return SIZE_MAX. |
no test coverage detected