summaryrefslogtreecommitdiffstats
path: root/lib/strutils.c
diff options
context:
space:
mode:
authorBenno Schulenberg2015-02-01 15:00:10 +0100
committerKarel Zak2015-02-02 10:57:07 +0100
commit25e3dd1739c9463cea1354ad9ad8401bced16768 (patch)
treebcd0b63c9c4e69d6c72c12b1bb0f5fad11b9448a /lib/strutils.c
parentcfdisk: make '?' an alias of 'h', to also show the help screen (diff)
downloadkernel-qcow2-util-linux-25e3dd1739c9463cea1354ad9ad8401bced16768.tar.gz
kernel-qcow2-util-linux-25e3dd1739c9463cea1354ad9ad8401bced16768.tar.xz
kernel-qcow2-util-linux-25e3dd1739c9463cea1354ad9ad8401bced16768.zip
lib/strutils: accept not just 'B' but also lowercase 'b' in a size suffix
Just line 'M' and 'm' are accepted for mega, 'G' and 'g' for giga, 'S' and 's' for sectors, and so on. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Diffstat (limited to 'lib/strutils.c')
-rw-r--r--lib/strutils.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/strutils.c b/lib/strutils.c
index 9fe9481bc..c4f9600b0 100644
--- a/lib/strutils.c
+++ b/lib/strutils.c
@@ -101,9 +101,9 @@ int parse_size(const char *str, uintmax_t *res, int *power)
* Check size suffixes
*/
check_suffix:
- if (*(p + 1) == 'i' && *(p + 2) == 'B' && !*(p + 3))
+ if (*(p + 1) == 'i' && (*(p + 2) == 'B' || *(p + 2) == 'b') && !*(p + 3))
base = 1024; /* XiB, 2^N */
- else if (*(p + 1) == 'B' && !*(p + 2))
+ else if ((*(p + 1) == 'B' || *(p + 1) == 'b') && !*(p + 2))
base = 1000; /* XB, 10^N */
else if (*(p + 1)) {
struct lconv const *l = localeconv();