From: Benno Schulenberg Date: Sun, 1 Feb 2015 14:00:10 +0000 (+0100) Subject: lib/strutils: accept not just 'B' but also lowercase 'b' in a size suffix X-Git-Tag: v2.26-rc2~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25e3dd1739c9463cea1354ad9ad8401bced16768;p=thirdparty%2Futil-linux.git 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 --- diff --git a/lib/strutils.c b/lib/strutils.c index 9fe9481bcf..c4f9600b05 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();