]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - lib/vsprintf.c
compiler*.h: sync include/linux/compiler*.h with Linux 4.5-rc6
[karo-tx-uboot.git] / lib / vsprintf.c
index a9b8a3ae67fa0817deefa3f1d5d559b97056eeb7..4c82837cc41e8e55899d945e8f27d399a0b0be71 100644 (file)
@@ -166,6 +166,25 @@ unsigned long long simple_strtoull(const char *cp, char **endp,
        return result;
 }
 
+long trailing_strtoln(const char *str, const char *end)
+{
+       const char *p;
+
+       if (!end)
+               end = str + strlen(str);
+       for (p = end - 1; p > str; p--) {
+               if (!isdigit(*p))
+                       return simple_strtoul(p + 1, NULL, 10);
+       }
+
+       return -1;
+}
+
+long trailing_strtol(const char *str)
+{
+       return trailing_strtoln(str, NULL);
+}
+
 /* we use this so that we can do without the ctype library */
 #define is_digit(c)    ((c) >= '0' && (c) <= '9')