MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / getoption

Function getoption

extlibs/lua/src/lstrlib.c:1443–1478  ·  view source on GitHub ↗

** Read and classify next option. 'size' is filled with option's size. */

Source from the content-addressed store, hash-verified

1441** Read and classify next option. 'size' is filled with option's size.
1442*/
1443static KOption getoption (Header *h, const char **fmt, int *size) {
1444 int opt = *((*fmt)++);
1445 *size = 0; /* default */
1446 switch (opt) {
1447 case 'b': *size = sizeof(char); return Kint;
1448 case 'B': *size = sizeof(char); return Kuint;
1449 case 'h': *size = sizeof(short); return Kint;
1450 case 'H': *size = sizeof(short); return Kuint;
1451 case 'l': *size = sizeof(long); return Kint;
1452 case 'L': *size = sizeof(long); return Kuint;
1453 case 'j': *size = sizeof(lua_Integer); return Kint;
1454 case 'J': *size = sizeof(lua_Integer); return Kuint;
1455 case 'T': *size = sizeof(size_t); return Kuint;
1456 case 'f': *size = sizeof(float); return Kfloat;
1457 case 'd': *size = sizeof(double); return Kfloat;
1458 case 'n': *size = sizeof(lua_Number); return Kfloat;
1459 case 'i': *size = getnumlimit(h, fmt, sizeof(int)); return Kint;
1460 case 'I': *size = getnumlimit(h, fmt, sizeof(int)); return Kuint;
1461 case 's': *size = getnumlimit(h, fmt, sizeof(size_t)); return Kstring;
1462 case 'c':
1463 *size = getnum(fmt, -1);
1464 if (*size == -1)
1465 luaL_error(h->L, "missing size for format option 'c'");
1466 return Kchar;
1467 case 'z': return Kzstr;
1468 case 'x': *size = 1; return Kpadding;
1469 case 'X': return Kpaddalign;
1470 case ' ': break;
1471 case '<': h->islittle = 1; break;
1472 case '>': h->islittle = 0; break;
1473 case '=': h->islittle = nativeendian.little; break;
1474 case '!': h->maxalign = getnumlimit(h, fmt, MAXALIGN); break;
1475 default: luaL_error(h->L, "invalid format option '%c'", opt);
1476 }
1477 return Knop;
1478}
1479
1480
1481/*

Callers 1

getdetailsFunction · 0.85

Calls 3

getnumlimitFunction · 0.85
getnumFunction · 0.85
luaL_errorFunction · 0.85

Tested by

no test coverage detected