static size_t SDL_ScanUintPtrT(const char *text, int radix, uintptr_t *valuep) { const char *textstart = text; uintptr_t value = 0; if ( radix == 16 && SDL_strncmp(text, "0x", 2) == 0 ) { text += 2; } for ( ; ; ) { int v; if ( SDL_isdigit((unsigned char) *text) ) { v = *text - '0'; } else if ( radix == 16 && SDL_isupperhex(*text) ) { v = 10 + (*text - 'A'); } else if ( radix == 16 && SDL_islowerhex(*text) ) { v = 10 + (*text - 'a'); } else { break; } value *= radix; value += v; ++text; } if ( valuep ) { *valuep = value; } return (text - textstart); }
static size_t SDL_ScanLong(const char *text, int radix, long *valuep) { const char *textstart = text; long value = 0; SDL_bool negative = SDL_FALSE; if (*text == '-') { negative = SDL_TRUE; ++text; } if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) { text += 2; } for (;;) { int v; if (SDL_isdigit((unsigned char) *text)) { v = *text - '0'; } else if (radix == 16 && SDL_isupperhex(*text)) { v = 10 + (*text - 'A'); } else if (radix == 16 && SDL_islowerhex(*text)) { v = 10 + (*text - 'a'); } else { break; } value *= radix; value += v; ++text; } if (valuep) { if (negative && value) { *valuep = -value; } else { *valuep = value; } } return (text - textstart); }