MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / l_str2int

Function l_str2int

src/Chain/libraries/glua/lobject.cpp:260–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258
259
260static const char *l_str2int(const char *s, lua_Integer *result) {
261 lua_Unsigned a = 0;
262 int empty = 1;
263 int neg;
264 while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */
265 neg = isneg(&s);
266 if (s[0] == '0' &&
267 (s[1] == 'x' || s[1] == 'X')) { /* hex? */
268 s += 2; /* skip '0x' */
269 for (; lisxdigit(cast_uchar(*s)); s++) {
270 a = a * 16 + luaO_hexavalue(*s);
271 empty = 0;
272 }
273 }
274 else { /* decimal */
275 for (; lisdigit(cast_uchar(*s)); s++) {
276 a = a * 10 + *s - '0';
277 empty = 0;
278 }
279 }
280 while (lisspace(cast_uchar(*s))) s++; /* skip trailing spaces */
281 if (empty || *s != '\0') return nullptr; /* something wrong in the numeral */
282 else {
283 *result = l_castU2S((neg) ? 0u - a : a);
284 return s;
285 }
286}
287
288
289size_t luaO_str2num(const char *s, TValue *o) {

Callers 1

luaO_str2numFunction · 0.85

Calls 2

luaO_hexavalueFunction · 0.85
isnegFunction · 0.70

Tested by

no test coverage detected