MCPcopy Create free account
hub / github.com/defold/defold / setpath

Function setpath

engine/lua/src/lua/loadlib.c:592–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

590#define AUXMARK "\1"
591
592static void setpath (lua_State *L, const char *fieldname, const char *envname,
593 const char *def) {
594#if defined(LUA_NO_GETENV) // DEFOLD
595 const char *path = 0; // DEFOLD
596#else
597 const char *path = getenv(envname);
598#endif
599 if (path == NULL) /* no environment variable? */
600 lua_pushstring(L, def); /* use default */
601 else {
602 /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */
603 path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP,
604 LUA_PATHSEP AUXMARK LUA_PATHSEP);
605 luaL_gsub(L, path, AUXMARK, def);
606 lua_remove(L, -2);
607 }
608 setprogdir(L);
609 lua_setfield(L, -2, fieldname);
610}
611
612
613static const luaL_Reg pk_funcs[] = {

Callers 1

luaopen_packageFunction · 0.85

Calls 6

getenvFunction · 0.85
lua_pushstringFunction · 0.85
luaL_gsubFunction · 0.85
lua_removeFunction · 0.85
setprogdirFunction · 0.85
lua_setfieldFunction · 0.85

Tested by

no test coverage detected