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

Function searcher_Croot

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

Source from the content-addressed store, hash-verified

586
587
588static int searcher_Croot (lua_State *L) {
589 const char *filename;
590 const char *name = luaL_checkstring(L, 1);
591 const char *p = strchr(name, '.');
592 int stat;
593 if (p == NULL) return 0; /* is root */
594 lua_pushlstring(L, name, p - name);
595 filename = findfile(L, lua_tostring(L, -1), "cpath", LUA_CSUBSEP);
596 if (filename == NULL) return 1; /* root not found */
597 if ((stat = loadfunc(L, filename, name)) != 0) {
598 if (stat != ERRFUNC)
599 return checkload(L, 0, filename); /* real error */
600 else { /* open function not found */
601 lua_pushfstring(L, "no module '%s' in file '%s'", name, filename);
602 return 1;
603 }
604 }
605 lua_pushstring(L, filename); /* will be 2nd argument to module */
606 return 2;
607}
608
609
610static int searcher_preload (lua_State *L) {

Callers

nothing calls this directly

Calls 6

lua_pushlstringFunction · 0.85
findfileFunction · 0.85
loadfuncFunction · 0.85
checkloadFunction · 0.85
lua_pushfstringFunction · 0.85
lua_pushstringFunction · 0.85

Tested by

no test coverage detected