diff options
Diffstat (limited to 'lib/vsprintf.c')
| -rw-r--r-- | lib/vsprintf.c | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index d7222a9c8267..c1a3927326eb 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
| @@ -31,17 +31,7 @@ | |||
| 31 | #include <asm/div64.h> | 31 | #include <asm/div64.h> |
| 32 | #include <asm/sections.h> /* for dereference_function_descriptor() */ | 32 | #include <asm/sections.h> /* for dereference_function_descriptor() */ |
| 33 | 33 | ||
| 34 | static unsigned int simple_guess_base(const char *cp) | 34 | #include "kstrtox.h" |
| 35 | { | ||
| 36 | if (cp[0] == '0') { | ||
| 37 | if (_tolower(cp[1]) == 'x' && isxdigit(cp[2])) | ||
| 38 | return 16; | ||
| 39 | else | ||
| 40 | return 8; | ||
| 41 | } else { | ||
| 42 | return 10; | ||
| 43 | } | ||
| 44 | } | ||
| 45 | 35 | ||
| 46 | /** | 36 | /** |
| 47 | * simple_strtoull - convert a string to an unsigned long long | 37 | * simple_strtoull - convert a string to an unsigned long long |
| @@ -51,23 +41,14 @@ static unsigned int simple_guess_base(const char *cp) | |||
| 51 | */ | 41 | */ |
| 52 | unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base) | 42 | unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base) |
| 53 | { | 43 | { |
| 54 | unsigned long long result = 0; | 44 | unsigned long long result; |
| 45 | unsigned int rv; | ||
| 55 | 46 | ||
| 56 | if (!base) | 47 | cp = _parse_integer_fixup_radix(cp, &base); |
| 57 | base = simple_guess_base(cp); | 48 | rv = _parse_integer(cp, base, &result); |
| 49 | /* FIXME */ | ||
| 50 | cp += (rv & ~KSTRTOX_OVERFLOW); | ||
| 58 | 51 | ||
| 59 | if (base == 16 && cp[0] == '0' && _tolower(cp[1]) == 'x') | ||
| 60 | cp += 2; | ||
| 61 | |||
| 62 | while (isxdigit(*cp)) { | ||
| 63 | unsigned int value; | ||
| 64 | |||
| 65 | value = isdigit(*cp) ? *cp - '0' : _tolower(*cp) - 'a' + 10; | ||
| 66 | if (value >= base) | ||
| 67 | break; | ||
| 68 | result = result * base + value; | ||
| 69 | cp++; | ||
| 70 | } | ||
| 71 | if (endp) | 52 | if (endp) |
| 72 | *endp = (char *)cp; | 53 | *endp = (char *)cp; |
| 73 | 54 | ||
