From 6b0b93bd30cb4e7a0047954a58d914b989c373a4 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Tue, 17 Dec 2024 02:53:56 -0500 Subject: fix -l option when used with -s/-S, accept k/K/m/M/g/G suffixes for -s/-S/-o/-l. --- uxd.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/uxd.c b/uxd.c index 1651a2f..59c16e9 100644 --- a/uxd.c +++ b/uxd.c @@ -205,9 +205,17 @@ long parse_number(int opt, const char *s) { result = strtol(s, &e, 0); - if(*e) { - fprintf(stderr, "%s: invalid number for -%c option.\n", self, opt); - exit(1); + switch(*e) { + case 0: break; + case 'k': result *= 1024L; break; + case 'm': result *= 1048576L; break; + case 'g': result *= 1073741824L; break; + case 'K': result *= 1000L; break; + case 'M': result *= 1000000L; break; + case 'G': result *= 1000000000L; break; + default: + fprintf(stderr, "%s: invalid number for -%c option.\n", self, opt); + exit(1); } return result; @@ -700,7 +708,7 @@ void print_info(void) { void dump_loop(void) { while(dump_utf8_char()) - if(limit && (filepos >= limit)) break; + if(limit && (byte_count >= limit)) break; /* handle the last line, if the file size not divisible by 16. */ if(dump_column) -- cgit v1.2.3