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

Function loadfunc

3rd/lua-5.4.3/src/loadlib.c:562–577  ·  view source on GitHub ↗

** Try to find a load function for module 'modname' at file 'filename'. ** First, change '.' to '_' in 'modname'; then, if 'modname' has ** the form X-Y (that is, it has an "ignore mark"), build a function ** name "luaopen_X" and look for it. (For compatibility, if that ** fails, it also tries "luaopen_Y".) If there is no ignore mark, ** look for a function named "luaopen_modname". */

Source from the content-addressed store, hash-verified

560** look for a function named "luaopen_modname".
561*/
562static int loadfunc (lua_State *L, const char *filename, const char *modname) {
563 const char *openfunc;
564 const char *mark;
565 modname = luaL_gsub(L, modname, ".", LUA_OFSEP);
566 mark = strchr(modname, *LUA_IGMARK);
567 if (mark) {
568 int stat;
569 openfunc = lua_pushlstring(L, modname, mark - modname);
570 openfunc = lua_pushfstring(L, LUA_POF"%s", openfunc);
571 stat = lookforfunc(L, filename, openfunc);
572 if (stat != ERRFUNC) return stat;
573 modname = mark + 1; /* else go ahead and try old-style name */
574 }
575 openfunc = lua_pushfstring(L, LUA_POF"%s", modname);
576 return lookforfunc(L, filename, openfunc);
577}
578
579
580static int searcher_C (lua_State *L) {

Callers 2

searcher_CFunction · 0.85
searcher_CrootFunction · 0.85

Calls 4

luaL_gsubFunction · 0.85
lua_pushlstringFunction · 0.85
lua_pushfstringFunction · 0.85
lookforfuncFunction · 0.85

Tested by

no test coverage detected