]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/strutils: accept not just 'B' but also lowercase 'b' in a size suffix
authorBenno Schulenberg <bensberg@justemail.net>
Sun, 1 Feb 2015 14:00:10 +0000 (15:00 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 2 Feb 2015 09:57:07 +0000 (10:57 +0100)
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>
lib/strutils.c

index 9fe9481bcf9194f03a9cdedd4c41a42a277859a3..c4f9600b0590a0ae28a5a5796a39ebe54afed7f8 100644 (file)
@@ -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();