| 385 | |
| 386 | |
| 387 | static int luaB_load (lua_State *L) { |
| 388 | int status; |
| 389 | size_t l; |
| 390 | const char *s = lua_tolstring(L, 1, &l); |
| 391 | const char *mode = luaL_optstring(L, 3, "bt"); |
| 392 | int env = (!lua_isnone(L, 4) ? 4 : 0); /* 'env' index or 0 if no 'env' */ |
| 393 | if (s != NULL) { /* loading a string? */ |
| 394 | const char *chunkname = luaL_optstring(L, 2, s); |
| 395 | status = luaL_loadbufferx(L, s, l, chunkname, mode); |
| 396 | } |
| 397 | else { /* loading from a reader function */ |
| 398 | const char *chunkname = luaL_optstring(L, 2, "=(load)"); |
| 399 | luaL_checktype(L, 1, LUA_TFUNCTION); |
| 400 | lua_settop(L, RESERVEDSLOT); /* create reserved slot */ |
| 401 | status = lua_load(L, generic_reader, NULL, chunkname, mode); |
| 402 | } |
| 403 | return load_aux(L, status, env); |
| 404 | } |
| 405 | |
| 406 | /* }====================================================== */ |
| 407 |
nothing calls this directly
no test coverage detected