Convert ARG, a string in base BASE, to an unsigned long value no greater than MAXVAL. On failure, diagnose with MSGID and exit. */
| 745 | |
| 746 | /* Convert ARG, a string in base BASE, to an unsigned long value no |
| 747 | greater than MAXVAL. On failure, diagnose with MSGID and exit. */ |
| 748 | static unsigned long |
| 749 | arg2num(char const *arg, int base, unsigned long maxval, char const *msgid) |
| 750 | { |
| 751 | unsigned long n; |
| 752 | char *ep; |
| 753 | errno = 0; |
| 754 | n = strtoul(arg, &ep, base); |
| 755 | if (ep == arg || *ep || maxval < n || errno) { |
| 756 | fprintf(stderr, _(msgid), progname, arg); |
| 757 | exit(EXIT_FAILURE); |
| 758 | } |
| 759 | return n; |
| 760 | } |
| 761 | |
| 762 | #ifndef MODE_T_MAX |
no outgoing calls
no test coverage detected