| 155 | |
| 156 | #if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOLL) |
| 157 | static size_t |
| 158 | SDL_ScanLongLong(const char *text, int radix, Sint64 * valuep) |
| 159 | { |
| 160 | const char *textstart = text; |
| 161 | Sint64 value = 0; |
| 162 | SDL_bool negative = SDL_FALSE; |
| 163 | |
| 164 | if (*text == '-') { |
| 165 | negative = SDL_TRUE; |
| 166 | ++text; |
| 167 | } |
| 168 | if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) { |
| 169 | text += 2; |
| 170 | } |
| 171 | for (;;) { |
| 172 | int v; |
| 173 | if (SDL_isdigit((unsigned char) *text)) { |
| 174 | v = *text - '0'; |
| 175 | } else if (radix == 16 && SDL_isupperhex(*text)) { |
| 176 | v = 10 + (*text - 'A'); |
| 177 | } else if (radix == 16 && SDL_islowerhex(*text)) { |
| 178 | v = 10 + (*text - 'a'); |
| 179 | } else { |
| 180 | break; |
| 181 | } |
| 182 | value *= radix; |
| 183 | value += v; |
| 184 | ++text; |
| 185 | } |
| 186 | if (valuep && text > textstart) { |
| 187 | if (negative && value) { |
| 188 | *valuep = -value; |
| 189 | } else { |
| 190 | *valuep = value; |
| 191 | } |
| 192 | } |
| 193 | return (text - textstart); |
| 194 | } |
| 195 | #endif |
| 196 | |
| 197 | #if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOULL) |
no test coverage detected