diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vsprintf.c | 48 |
1 files changed, 14 insertions, 34 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index a315138ece55..c50733a690f0 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -47,14 +47,14 @@ static unsigned int simple_guess_base(const char *cp) | |||
47 | } | 47 | } |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * simple_strtoul - convert a string to an unsigned long | 50 | * simple_strtoull - convert a string to an unsigned long long |
51 | * @cp: The start of the string | 51 | * @cp: The start of the string |
52 | * @endp: A pointer to the end of the parsed string will be placed here | 52 | * @endp: A pointer to the end of the parsed string will be placed here |
53 | * @base: The number base to use | 53 | * @base: The number base to use |
54 | */ | 54 | */ |
55 | unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base) | 55 | unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base) |
56 | { | 56 | { |
57 | unsigned long result = 0; | 57 | unsigned long long result = 0; |
58 | 58 | ||
59 | if (!base) | 59 | if (!base) |
60 | base = simple_guess_base(cp); | 60 | base = simple_guess_base(cp); |
@@ -76,54 +76,34 @@ unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base) | |||
76 | 76 | ||
77 | return result; | 77 | return result; |
78 | } | 78 | } |
79 | EXPORT_SYMBOL(simple_strtoul); | 79 | EXPORT_SYMBOL(simple_strtoull); |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * simple_strtol - convert a string to a signed long | 82 | * simple_strtoul - convert a string to an unsigned long |
83 | * @cp: The start of the string | 83 | * @cp: The start of the string |
84 | * @endp: A pointer to the end of the parsed string will be placed here | 84 | * @endp: A pointer to the end of the parsed string will be placed here |
85 | * @base: The number base to use | 85 | * @base: The number base to use |
86 | */ | 86 | */ |
87 | long simple_strtol(const char *cp, char **endp, unsigned int base) | 87 | unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base) |
88 | { | 88 | { |
89 | if (*cp == '-') | 89 | return simple_strtoull(cp, endp, base); |
90 | return -simple_strtoul(cp + 1, endp, base); | ||
91 | |||
92 | return simple_strtoul(cp, endp, base); | ||
93 | } | 90 | } |
94 | EXPORT_SYMBOL(simple_strtol); | 91 | EXPORT_SYMBOL(simple_strtoul); |
95 | 92 | ||
96 | /** | 93 | /** |
97 | * simple_strtoull - convert a string to an unsigned long long | 94 | * simple_strtol - convert a string to a signed long |
98 | * @cp: The start of the string | 95 | * @cp: The start of the string |
99 | * @endp: A pointer to the end of the parsed string will be placed here | 96 | * @endp: A pointer to the end of the parsed string will be placed here |
100 | * @base: The number base to use | 97 | * @base: The number base to use |
101 | */ | 98 | */ |
102 | unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base) | 99 | long simple_strtol(const char *cp, char **endp, unsigned int base) |
103 | { | 100 | { |
104 | unsigned long long result = 0; | 101 | if (*cp == '-') |
105 | 102 | return -simple_strtoul(cp + 1, endp, base); | |
106 | if (!base) | ||
107 | base = simple_guess_base(cp); | ||
108 | |||
109 | if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x') | ||
110 | cp += 2; | ||
111 | |||
112 | while (isxdigit(*cp)) { | ||
113 | unsigned int value; | ||
114 | |||
115 | value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10; | ||
116 | if (value >= base) | ||
117 | break; | ||
118 | result = result * base + value; | ||
119 | cp++; | ||
120 | } | ||
121 | if (endp) | ||
122 | *endp = (char *)cp; | ||
123 | 103 | ||
124 | return result; | 104 | return simple_strtoul(cp, endp, base); |
125 | } | 105 | } |
126 | EXPORT_SYMBOL(simple_strtoull); | 106 | EXPORT_SYMBOL(simple_strtol); |
127 | 107 | ||
128 | /** | 108 | /** |
129 | * simple_strtoll - convert a string to a signed long long | 109 | * simple_strtoll - convert a string to a signed long long |