aboutsummaryrefslogtreecommitdiff
path: root/uxd.c
diff options
context:
space:
mode:
Diffstat (limited to 'uxd.c')
-rw-r--r--uxd.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/uxd.c b/uxd.c
index e5317ce..ef86bb7 100644
--- a/uxd.c
+++ b/uxd.c
@@ -250,11 +250,12 @@ long parse_number(int opt, const char *s) {
if(e == s)
number_err(opt);
- /* buglets here: 100x is correctly rejected, but 100kx is allowed
- (the x is ignored). not gonna worry about it. some people might
- even make use of it: 100kb or 100Kb will work. */
- switch(*e) {
+ switch(e[0]) {
case 0: break;
+ case 'b':
+ case 'B':
+ if(e[1]) number_err(opt);
+ break; /* allow & ignore b/B for "bytes" */
case 'k': result *= 1024L; break;
case 'm': result *= 1048576L; break;
case 'g': result *= 1073741824L; break;
@@ -265,6 +266,10 @@ long parse_number(int opt, const char *s) {
number_err(opt);
}
+ /* allow e.g. "kb" for kilobytes (but reject e.g. "kx") */
+ if(e[0] && e[1] && e[1] != 'b' && e[1] != 'B')
+ number_err(opt);
+
return result;
}