fixes negative seek error

This commit is contained in:
SuperNovaa41 2025-02-12 14:13:12 -05:00
parent f4ab18171a
commit ec3a1d44d4
2 changed files with 3 additions and 2 deletions

View File

@ -30,7 +30,7 @@ struct flags {
bool littleendian; bool littleendian;
uint offset; uint offset;
uint seek; int seek;
uint octets; // number of octets per line (default 2) // done uint octets; // number of octets per line (default 2) // done
bool customoctets; bool customoctets;

View File

@ -134,7 +134,8 @@ static void do_text_parse(hex_chunk_t** lines, bool interactive)
fprintf(stderr, "xxd: Sorry, cannot seek.\n"); fprintf(stderr, "xxd: Sorry, cannot seek.\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
seek = (strlen(file_content) - flags.seek); seek = (strlen(file_content) - (flags.seek * -1));
flags.offset += seek;
} }
filesize = (flags.len == -1) ? strlen(file_content + seek) : flags.len; filesize = (flags.len == -1) ? strlen(file_content + seek) : flags.len;