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

Function SDL_ScanUnsignedLong

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

Source from the content-addressed store, hash-verified

91
92#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOUL) || !defined(HAVE_STRTOD)
93static size_t
94SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
95{
96 const char *textstart = text;
97 unsigned long value = 0;
98
99 if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
100 text += 2;
101 }
102 for (;;) {
103 int v;
104 if (SDL_isdigit((unsigned char) *text)) {
105 v = *text - '0';
106 } else if (radix == 16 && SDL_isupperhex(*text)) {
107 v = 10 + (*text - 'A');
108 } else if (radix == 16 && SDL_islowerhex(*text)) {
109 v = 10 + (*text - 'a');
110 } else {
111 break;
112 }
113 value *= radix;
114 value += v;
115 ++text;
116 }
117 if (valuep && text > textstart) {
118 *valuep = value;
119 }
120 return (text - textstart);
121}
122#endif
123
124#ifndef HAVE_VSSCANF

Callers 3

SDL_ScanFloatFunction · 0.85
SDL_strtoulFunction · 0.85
SDL_vsscanfFunction · 0.85

Calls 2

SDL_strncmpFunction · 0.85
SDL_isdigitFunction · 0.85

Tested by

no test coverage detected