- if (argc == 1) {
- if (parse_old_offset(argv[0], &o1)) {
- n_bytes_to_skip = o1;
- --argc;
- ++argv;
- }
- } else if (argc == 2) {
- if (parse_old_offset(argv[0], &o1)
- && parse_old_offset(argv[1], &o2)
- ) {
- n_bytes_to_skip = o1;
- flag_pseudo_start = 1;
- pseudo_start = o2;
- argv += 2;
- argc -= 2;
- } else if (parse_old_offset(argv[1], &o2)) {
- n_bytes_to_skip = o2;
- --argc;
- argv[1] = argv[0];
- ++argv;
- } else {
- bb_error_msg_and_die("invalid second operand "
- "in compatibility mode '%s'", argv[1]);
- }
- } else if (argc == 3) {
- if (parse_old_offset(argv[1], &o1)
- && parse_old_offset(argv[2], &o2)
- ) {
- n_bytes_to_skip = o1;
- flag_pseudo_start = 1;
- pseudo_start = o2;
- argv[2] = argv[0];
- argv += 2;
- argc -= 2;
- } else {
- bb_error_msg_and_die("in compatibility mode "
- "the last two arguments must be offsets");
+ if (argv[0]) {
+ if (!argv[1]) { /* one arg */
+ if (parse_old_offset(argv[0], &o1)) {
+ /* od --traditional OFFSET */
+ n_bytes_to_skip = o1;
+ argv++;
+ }
+ /* od --traditional FILE */
+ } else if (!argv[2]) { /* two args */
+ if (parse_old_offset(argv[0], &o1)
+ && parse_old_offset(argv[1], &o2)
+ ) {
+ /* od --traditional OFFSET LABEL */
+ n_bytes_to_skip = o1;
+ flag_pseudo_start = 1;
+ pseudo_start = o2;
+ argv += 2;
+ } else if (parse_old_offset(argv[1], &o2)) {
+ /* od --traditional FILE OFFSET */
+ n_bytes_to_skip = o2;
+ argv[1] = NULL;
+ } else {
+ bb_error_msg_and_die("invalid second argument '%s'", argv[1]);
+ }
+ } else if (!argv[3]) { /* three args */
+ if (parse_old_offset(argv[1], &o1)
+ && parse_old_offset(argv[2], &o2)
+ ) {
+ /* od --traditional FILE OFFSET LABEL */
+ n_bytes_to_skip = o1;
+ flag_pseudo_start = 1;
+ pseudo_start = o2;
+ argv[1] = NULL;
+ } else {
+ bb_error_msg_and_die("the last two arguments must be offsets");
+ }
+ } else { /* >3 args */
+ bb_error_msg_and_die("too many arguments");