MCPcopy Create free account
hub / github.com/DFHack/dfhack / getoption

Function getoption

depends/lua/src/lstrlib.c:1221–1256  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1219** Read and classify next option. 'size' is filled with option's size.
1220*/
1221static KOption getoption (Header *h, const char **fmt, int *size) {
1222 int opt = *((*fmt)++);
1223 *size = 0; /* default */
1224 switch (opt) {
1225 case 'b': *size = sizeof(char); return Kint;
1226 case 'B': *size = sizeof(char); return Kuint;
1227 case 'h': *size = sizeof(short); return Kint;
1228 case 'H': *size = sizeof(short); return Kuint;
1229 case 'l': *size = sizeof(long); return Kint;
1230 case 'L': *size = sizeof(long); return Kuint;
1231 case 'j': *size = sizeof(lua_Integer); return Kint;
1232 case 'J': *size = sizeof(lua_Integer); return Kuint;
1233 case 'T': *size = sizeof(size_t); return Kuint;
1234 case 'f': *size = sizeof(float); return Kfloat;
1235 case 'd': *size = sizeof(double); return Kfloat;
1236 case 'n': *size = sizeof(lua_Number); return Kfloat;
1237 case 'i': *size = getnumlimit(h, fmt, sizeof(int)); return Kint;
1238 case 'I': *size = getnumlimit(h, fmt, sizeof(int)); return Kuint;
1239 case 's': *size = getnumlimit(h, fmt, sizeof(size_t)); return Kstring;
1240 case 'c':
1241 *size = getnum(fmt, -1);
1242 if (*size == -1)
1243 luaL_error(h->L, "missing size for format option 'c'");
1244 return Kchar;
1245 case 'z': return Kzstr;
1246 case 'x': *size = 1; return Kpadding;
1247 case 'X': return Kpaddalign;
1248 case ' ': break;
1249 case '<': h->islittle = 1; break;
1250 case '>': h->islittle = 0; break;
1251 case '=': h->islittle = nativeendian.little; break;
1252 case '!': h->maxalign = getnumlimit(h, fmt, MAXALIGN); break;
1253 default: luaL_error(h->L, "invalid format option '%c'", opt);
1254 }
1255 return Knop;
1256}
1257
1258
1259/*

Callers 1

getdetailsFunction · 0.85

Calls 3

getnumlimitFunction · 0.85
getnumFunction · 0.85
luaL_errorFunction · 0.85

Tested by

no test coverage detected