MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / getoption

Function getoption

3rd/lua-5.4.3/src/lstrlib.c:1437–1472  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 1

getdetailsFunction · 0.85

Calls 3

getnumlimitFunction · 0.85
getnumFunction · 0.85
luaL_errorFunction · 0.85

Tested by

no test coverage detected