diff options
-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) |