- while (!feof(fp)) {
- int col = 0;
- int tmp;
-
- // Each line of a non-plain hexdump starts with an offset/address.
- if (!(toys.optflags&FLAG_p)) {
- long long pos;
-
- if (fscanf(fp, "%llx: ", &pos) == 1) {
- if (fseek(stdout, pos, SEEK_SET) != 0) {
- // TODO: just write out zeros if non-seekable?
- perror_exit("%s: seek failed", name);
+ if (toys.optflags&FLAG_i) {
+ // -ri is a very easy special case.
+ while (fscanf(fp, " 0x%02x,", &tmp) == 1) {
+ fputc(tmp & 0xff, stdout);
+ }
+ } else {
+ while (!feof(fp)) {
+ int col = 0;
+
+ // Each line of a regular hexdump starts with an offset/address.
+ // Each line of a plain hexdump just goes straight into the bytes.
+ if (!(toys.optflags&FLAG_p)) {
+ long long pos;
+
+ if (fscanf(fp, "%llx: ", &pos) == 1) {
+ if (fseek(stdout, pos, SEEK_SET) != 0) {
+ // TODO: just write out zeros if non-seekable?
+ perror_exit("%s: seek failed", name);
+ }