diff options
author | pjd <pjd@FreeBSD.org> | 2004-07-31 15:13:08 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2004-07-31 15:13:08 +0000 |
commit | a9d4d391b87414e9e085b73761ac3d5c0b6eb564 (patch) | |
tree | c80ff5d1d249f845da4a7b205d6b23a5030b213a /bin/dd | |
parent | 55224f76bfb5473dec65ddb959abd438a72fc81f (diff) | |
download | FreeBSD-src-a9d4d391b87414e9e085b73761ac3d5c0b6eb564.zip FreeBSD-src-a9d4d391b87414e9e085b73761ac3d5c0b6eb564.tar.gz |
Allow for capital letters as size suffixes.
Inspired by: le
Approved by: green (maintainer)
Diffstat (limited to 'bin/dd')
-rw-r--r-- | bin/dd/args.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/bin/dd/args.c b/bin/dd/args.c index 9d87c70..c4d418b 100644 --- a/bin/dd/args.c +++ b/bin/dd/args.c @@ -336,14 +336,14 @@ c_conv(const void *a, const void *b) /* * Convert an expression of the following forms to a uintmax_t. * 1) A positive decimal number. - * 2) A positive decimal number followed by a b (mult by 512). - * 3) A positive decimal number followed by a k (mult by 1 << 10). - * 4) A positive decimal number followed by a m (mult by 1 << 20). - * 5) A positive decimal number followed by a g (mult by 1 << 30). - * 5) A positive decimal number followed by a w (mult by sizeof int). - * 6) Two or more positive decimal numbers (with/without [bkmgw]) - * separated by x (also * for backwards compatibility), specifying - * the product of the indicated values. + * 2) A positive decimal number followed by a 'b' or 'B' (mult by 512). + * 3) A positive decimal number followed by a 'k' or 'K' (mult by 1 << 10). + * 4) A positive decimal number followed by a 'm' or 'M' (mult by 1 << 20). + * 5) A positive decimal number followed by a 'g' or 'G' (mult by 1 << 30). + * 5) A positive decimal number followed by a 'w' or 'W' (mult by sizeof int). + * 6) Two or more positive decimal numbers (with/without [BbKkMmGgWw]) + * separated by 'x' or 'X' (also '*' for backwards compatibility), + * specifying the product of the indicated values. */ static uintmax_t get_num(const char *val) @@ -361,18 +361,23 @@ get_num(const char *val) mult = 0; switch (*expr) { + case 'B': case 'b': mult = 512; break; + case 'K': case 'k': mult = 1 << 10; break; + case 'M': case 'm': mult = 1 << 20; break; + case 'G': case 'g': mult = 1 << 30; break; + case 'W': case 'w': mult = sizeof(int); break; @@ -393,6 +398,7 @@ get_num(const char *val) case '\0': break; case '*': /* Backward compatible. */ + case 'X': case 'x': mult = get_num(expr + 1); prevnum = num; @@ -429,18 +435,23 @@ get_off_t(const char *val) mult = 0; switch (*expr) { + case 'B': case 'b': mult = 512; break; + case 'K': case 'k': mult = 1 << 10; break; + case 'M': case 'm': mult = 1 << 20; break; + case 'G': case 'g': mult = 1 << 30; break; + case 'W': case 'w': mult = sizeof(int); break; @@ -459,6 +470,7 @@ get_off_t(const char *val) case '\0': break; case '*': /* Backward compatible. */ + case 'X': case 'x': mult = (intmax_t)get_off_t(expr + 1); prevnum = num; |