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

Function SDL_ScanFloat

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

Source from the content-addressed store, hash-verified

228
229#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOD)
230static size_t
231SDL_ScanFloat(const char *text, double *valuep)
232{
233 const char *textstart = text;
234 unsigned long lvalue = 0;
235 double value = 0.0;
236 SDL_bool negative = SDL_FALSE;
237
238 if (*text == '-') {
239 negative = SDL_TRUE;
240 ++text;
241 }
242 text += SDL_ScanUnsignedLong(text, 10, &lvalue);
243 value += lvalue;
244 if (*text == '.') {
245 int mult = 10;
246 ++text;
247 while (SDL_isdigit((unsigned char) *text)) {
248 lvalue = *text - '0';
249 value += (double) lvalue / mult;
250 mult *= 10;
251 ++text;
252 }
253 }
254 if (valuep && text > textstart) {
255 if (negative && value) {
256 *valuep = -value;
257 } else {
258 *valuep = value;
259 }
260 }
261 return (text - textstart);
262}
263#endif
264
265void *

Callers 2

SDL_strtodFunction · 0.85
SDL_vsscanfFunction · 0.85

Calls 2

SDL_ScanUnsignedLongFunction · 0.85
SDL_isdigitFunction · 0.85

Tested by

no test coverage detected