MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / getoption

Function getoption

third-party/lua-5.5.0/src/lstrlib.c:1492–1533  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1490** Read and classify next option. 'size' is filled with option's size.
1491*/
1492static KOption getoption (Header *h, const char **fmt, size_t *size) {
1493 /* dummy structure to get native alignment requirements */
1494 struct cD { char c; union { LUAI_MAXALIGN; } u; };
1495 int opt = *((*fmt)++);
1496 *size = 0; /* default */
1497 switch (opt) {
1498 case 'b': *size = sizeof(char); return Kint;
1499 case 'B': *size = sizeof(char); return Kuint;
1500 case 'h': *size = sizeof(short); return Kint;
1501 case 'H': *size = sizeof(short); return Kuint;
1502 case 'l': *size = sizeof(long); return Kint;
1503 case 'L': *size = sizeof(long); return Kuint;
1504 case 'j': *size = sizeof(lua_Integer); return Kint;
1505 case 'J': *size = sizeof(lua_Integer); return Kuint;
1506 case 'T': *size = sizeof(size_t); return Kuint;
1507 case 'f': *size = sizeof(float); return Kfloat;
1508 case 'n': *size = sizeof(lua_Number); return Knumber;
1509 case 'd': *size = sizeof(double); return Kdouble;
1510 case 'i': *size = getnumlimit(h, fmt, sizeof(int)); return Kint;
1511 case 'I': *size = getnumlimit(h, fmt, sizeof(int)); return Kuint;
1512 case 's': *size = getnumlimit(h, fmt, sizeof(size_t)); return Kstring;
1513 case 'c':
1514 *size = getnum(fmt, cast_sizet(-1));
1515 if (l_unlikely(*size == cast_sizet(-1)))
1516 luaL_error(h->L, "missing size for format option 'c'");
1517 return Kchar;
1518 case 'z': return Kzstr;
1519 case 'x': *size = 1; return Kpadding;
1520 case 'X': return Kpaddalign;
1521 case ' ': break;
1522 case '<': h->islittle = 1; break;
1523 case '>': h->islittle = 0; break;
1524 case '=': h->islittle = nativeendian.little; break;
1525 case '!': {
1526 const size_t maxalign = offsetof(struct cD, u);
1527 h->maxalign = getnumlimit(h, fmt, maxalign);
1528 break;
1529 }
1530 default: luaL_error(h->L, "invalid format option '%c'", opt);
1531 }
1532 return Knop;
1533}
1534
1535
1536/*

Callers 1

getdetailsFunction · 0.70

Calls 3

getnumlimitFunction · 0.70
getnumFunction · 0.70
luaL_errorFunction · 0.70

Tested by

no test coverage detected