197 {
198 if (!str) {
199 if (endptr) {
200 *endptr = const_cast<char*>(str);
201 }
202 return 0;
203 }
204
205 const char* p = str;
207
208
209 while (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r' || *p == '\f' || *p == '\v') {
210 p++;
211 }
212
213
214 if (*p == '+') {
215 p++;
216 } else if (*p == '-') {
217
218 p++;
219 }
220
221
222 if (base == 0) {
223 if (*p == '0') {
224 if (*(p + 1) == 'x' || *(p + 1) == 'X') {
225 base = 16;
226 p += 2;
227 } else {
228 base = 8;
229 p++;
230 }
231 } else {
232 base = 10;
233 }
234 } else if (base == 16) {
235
236 if (*p == '0' && (*(p + 1) == 'x' || *(p + 1) == 'X')) {
237 p += 2;
238 }
239 }
240
241
242 if (base < 2 || base > 36) {
243 if (endptr) {
244 *endptr = const_cast<char*>(str);
245 }
246 return 0;
247 }
248
249
250 const char* start = p;
253 p++;
254 }
255
256
257 if (endptr) {
258 if (p == start) {
259
260 *endptr = const_cast<char*>(str);
261 } else {
262 *endptr = const_cast<char*>(p);
263 }
264 }
265
267}
static int charToDigit(char c) FL_NO_EXCEPT
expected< T, E > result
Alias for expected (Rust-style naming)
static bool isDigitInBase(char c, int base) FL_NO_EXCEPT