diff options
author | B. Watson <urchlay@slackware.uk> | 2024-12-17 02:53:56 -0500 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-12-17 02:53:56 -0500 |
commit | 6b0b93bd30cb4e7a0047954a58d914b989c373a4 (patch) | |
tree | 95387b18718b58f45f38df4116cdcc7fd620f89f /uxd.c | |
parent | 96f379ca98ed54c3571c35e2b1f9e532e2a863b1 (diff) | |
download | uxd-6b0b93bd30cb4e7a0047954a58d914b989c373a4.tar.gz |
fix -l option when used with -s/-S, accept k/K/m/M/g/G suffixes for -s/-S/-o/-l.
Diffstat (limited to 'uxd.c')
-rw-r--r-- | uxd.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -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) |