MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / SDL_ScanLongLong

Function SDL_ScanLongLong

deps/SDL2/src/stdlib/SDL_string.c:157–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155
156#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOLL)
157static size_t
158SDL_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)

Callers 2

SDL_strtollFunction · 0.85
SDL_vsscanfFunction · 0.85

Calls 2

SDL_strncmpFunction · 0.85
SDL_isdigitFunction · 0.85

Tested by

no test coverage detected