X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=lib%2Fvsprintf.c;h=4c82837cc41e8e55899d945e8f27d399a0b0be71;hb=baaaa7539c7511e7e90453ecf0f20d8eaeeb70c6;hp=a9b8a3ae67fa0817deefa3f1d5d559b97056eeb7;hpb=808bf7cf655a1caa5f48f6f3a6b274f4b83ab8b4;p=u-boot diff --git a/lib/vsprintf.c b/lib/vsprintf.c index a9b8a3ae67..4c82837cc4 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -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')