| 1474 | } |
| 1475 | |
| 1476 | static void |
| 1477 | scanargs (int argc, char *const *argv) |
| 1478 | { |
| 1479 | idx_t blocksize = 0; |
| 1480 | intmax_t count = INTMAX_MAX; |
| 1481 | intmax_t skip = 0; |
| 1482 | intmax_t seek = 0; |
| 1483 | bool count_B = false, skip_B = false, seek_B = false; |
| 1484 | |
| 1485 | for (int i = optind; i < argc; i++) |
| 1486 | { |
| 1487 | char const *name = argv[i]; |
| 1488 | char const *val = strchr (name, '='); |
| 1489 | |
| 1490 | if (val == NULL) |
| 1491 | { |
| 1492 | diagnose (0, _("unrecognized operand %s"), quoteaf (name)); |
| 1493 | usage (EXIT_FAILURE); |
| 1494 | } |
| 1495 | val++; |
| 1496 | |
| 1497 | if (operand_is (name, "if")) |
| 1498 | input_file = val; |
| 1499 | else if (operand_is (name, "of")) |
| 1500 | output_file = val; |
| 1501 | else if (operand_is (name, "conv")) |
| 1502 | conversions_mask |= parse_symbols (val, conversions, false, |
| 1503 | N_("invalid conversion")); |
| 1504 | else if (operand_is (name, "iflag")) |
| 1505 | input_flags |= parse_symbols (val, flags, false, |
| 1506 | N_("invalid input flag")); |
| 1507 | else if (operand_is (name, "oflag")) |
| 1508 | output_flags |= parse_symbols (val, flags, false, |
| 1509 | N_("invalid output flag")); |
| 1510 | else if (operand_is (name, "status")) |
| 1511 | status_level = parse_symbols (val, statuses, true, |
| 1512 | N_("invalid status level")); |
| 1513 | else |
| 1514 | { |
| 1515 | strtol_error invalid = LONGINT_OK; |
| 1516 | intmax_t n = parse_integer (val, &invalid); |
| 1517 | bool has_B = !!strchr (val, 'B'); |
| 1518 | intmax_t n_min = 0; |
| 1519 | intmax_t n_max = INTMAX_MAX; |
| 1520 | idx_t *converted_idx = NULL; |
| 1521 | |
| 1522 | /* Maximum blocksize. Keep it smaller than IDX_MAX, so that |
| 1523 | it fits into blocksize vars even if 1 is added for conv=swab. |
| 1524 | Do not exceed SSIZE_MAX, for the benefit of system calls |
| 1525 | like "read". And do not exceed OFF_T_MAX, for the |
| 1526 | benefit of the large-offset seek code. */ |
| 1527 | idx_t max_blocksize = MIN (IDX_MAX - 1, MIN (SSIZE_MAX, OFF_T_MAX)); |
| 1528 | |
| 1529 | if (operand_is (name, "ibs")) |
| 1530 | { |
| 1531 | n_min = 1; |
| 1532 | n_max = max_blocksize; |
| 1533 | converted_idx = &input_blocksize; |
no test coverage detected