124 {
125 if (!str) {
126 if (endptr) {
127 *endptr = const_cast<char*>(str);
128 }
129 return 0;
130 }
131
132 const char* p = str;
134 bool negative = false;
135
136
137 while (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r' || *p == '\f' || *p == '\v') {
138 p++;
139 }
140
141
142 if (*p == '-') {
143 negative = true;
144 p++;
145 } else if (*p == '+') {
146 p++;
147 }
148
149
150 if (base == 0) {
151 if (*p == '0') {
152 if (*(p + 1) == 'x' || *(p + 1) == 'X') {
153 base = 16;
154 p += 2;
155 } else {
156 base = 8;
157 p++;
158 }
159 } else {
160 base = 10;
161 }
162 } else if (base == 16) {
163
164 if (*p == '0' && (*(p + 1) == 'x' || *(p + 1) == 'X')) {
165 p += 2;
166 }
167 }
168
169
170 if (base < 2 || base > 36) {
171 if (endptr) {
172 *endptr = const_cast<char*>(str);
173 }
174 return 0;
175 }
176
177
178 const char* start = p;
181 p++;
182 }
183
184
185 if (endptr) {
186 if (p == start) {
187
188 *endptr = const_cast<char*>(str);
189 } else {
190 *endptr = const_cast<char*>(p);
191 }
192 }
193
195}
static int charToDigit(char c) FL_NO_EXCEPT
expected< T, E > result
Alias for expected (Rust-style naming)
static bool isDigitInBase(char c, int base) FL_NO_EXCEPT