| 445 | |
| 446 | |
| 447 | static int luaB_load(lua_State *L) { |
| 448 | int status; |
| 449 | size_t l; |
| 450 | const char *s = lua_tolstring(L, 1, &l); |
| 451 | const char *mode = luaL_optstring(L, 3, "bt"); |
| 452 | int env = (!lua_isnone(L, 4) ? 4 : 0); /* 'env' index or 0 if no 'env' */ |
| 453 | if (s != nullptr) { /* loading a string? */ |
| 454 | const char *chunkname = luaL_optstring(L, 2, s); |
| 455 | status = luaL_loadbufferx(L, s, l, chunkname, mode); |
| 456 | } |
| 457 | else { /* loading from a reader function */ |
| 458 | const char *chunkname = luaL_optstring(L, 2, "=(load)"); |
| 459 | luaL_checktype(L, 1, LUA_TFUNCTION); |
| 460 | lua_settop(L, RESERVEDSLOT); /* create reserved slot */ |
| 461 | status = lua_load(L, generic_reader, nullptr, chunkname, mode); |
| 462 | } |
| 463 | return load_aux(L, status, env); |
| 464 | } |
| 465 | |
| 466 | /* }====================================================== */ |
| 467 |
nothing calls this directly
no test coverage detected