aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-12-17 02:53:56 -0500
committerB. Watson <urchlay@slackware.uk>2024-12-17 02:53:56 -0500
commit6b0b93bd30cb4e7a0047954a58d914b989c373a4 (patch)
tree95387b18718b58f45f38df4116cdcc7fd620f89f
parent96f379ca98ed54c3571c35e2b1f9e532e2a863b1 (diff)
downloaduxd-6b0b93bd30cb4e7a0047954a58d914b989c373a4.tar.gz
fix -l option when used with -s/-S, accept k/K/m/M/g/G suffixes for -s/-S/-o/-l.
-rw-r--r--uxd.c16
1 files 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)