]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - lib/vsprintf.c
New command bootmenu: ANSI terminal boot menu support
[karo-tx-uboot.git] / lib / vsprintf.c
index dd13bca5a73d73c0924b67d7333bdc501b810eea..533a96b85e3629a765ba807a594f8509fab9f68a 100644 (file)
@@ -28,7 +28,7 @@
 /* some reluctance to put this into a new limits.h, so it is here */
 #define INT_MAX                ((int)(~0U>>1))
 
-const char hex_asc[] = "0123456789abcdef";
+static const char hex_asc[] = "0123456789abcdef";
 #define hex_asc_lo(x)   hex_asc[((x) & 0x0f)]
 #define hex_asc_hi(x)   hex_asc[((x) & 0xf0) >> 4]
 
@@ -103,7 +103,7 @@ long simple_strtol(const char *cp, char **endp, unsigned int base)
        return simple_strtoul(cp, endp, base);
 }
 
-int ustrtoul(const char *cp, char **endp, unsigned int base)
+unsigned long ustrtoul(const char *cp, char **endp, unsigned int base)
 {
        unsigned long result = simple_strtoul(cp, endp, base);
        switch (**endp) {
@@ -126,6 +126,29 @@ int ustrtoul(const char *cp, char **endp, unsigned int base)
        return result;
 }
 
+unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base)
+{
+       unsigned long long result = simple_strtoull(cp, endp, base);
+       switch (**endp) {
+       case 'G':
+               result *= 1024;
+               /* fall through */
+       case 'M':
+               result *= 1024;
+               /* fall through */
+       case 'K':
+       case 'k':
+               result *= 1024;
+               if ((*endp)[1] == 'i') {
+                       if ((*endp)[2] == 'B')
+                               (*endp) += 3;
+                       else
+                               (*endp) += 2;
+               }
+       }
+       return result;
+}
+
 unsigned long long simple_strtoull(const char *cp, char **endp,
                                        unsigned int base)
 {
@@ -395,7 +418,7 @@ static char *string(char *buf, char *end, char *s, int field_width,
 {
        int len, i;
 
-       if (s == 0)
+       if (s == NULL)
                s = "<NULL>";
 
        len = strnlen(s, precision);