| 50 | |
| 51 | #if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOL) |
| 52 | static size_t |
| 53 | SDL_ScanLong(const char *text, int radix, long *valuep) |
| 54 | { |
| 55 | const char *textstart = text; |
| 56 | long value = 0; |
| 57 | SDL_bool negative = SDL_FALSE; |
| 58 | |
| 59 | if (*text == '-') { |
| 60 | negative = SDL_TRUE; |
| 61 | ++text; |
| 62 | } |
| 63 | if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) { |
| 64 | text += 2; |
| 65 | } |
| 66 | for (;;) { |
| 67 | int v; |
| 68 | if (SDL_isdigit((unsigned char) *text)) { |
| 69 | v = *text - '0'; |
| 70 | } else if (radix == 16 && SDL_isupperhex(*text)) { |
| 71 | v = 10 + (*text - 'A'); |
| 72 | } else if (radix == 16 && SDL_islowerhex(*text)) { |
| 73 | v = 10 + (*text - 'a'); |
| 74 | } else { |
| 75 | break; |
| 76 | } |
| 77 | value *= radix; |
| 78 | value += v; |
| 79 | ++text; |
| 80 | } |
| 81 | if (valuep && text > textstart) { |
| 82 | if (negative && value) { |
| 83 | *valuep = -value; |
| 84 | } else { |
| 85 | *valuep = value; |
| 86 | } |
| 87 | } |
| 88 | return (text - textstart); |
| 89 | } |
| 90 | #endif |
| 91 | |
| 92 | #if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOUL) || !defined(HAVE_STRTOD) |
no test coverage detected