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

Function SDL_ScanLong

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

Source from the content-addressed store, hash-verified

50
51#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOL)
52static size_t
53SDL_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)

Callers 2

SDL_strtolFunction · 0.85
SDL_vsscanfFunction · 0.85

Calls 2

SDL_strncmpFunction · 0.85
SDL_isdigitFunction · 0.85

Tested by

no test coverage detected