MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / setpath

Function setpath

deps/lua/src/loadlib.c:592–606  ·  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 const char *path = getenv(envname);
595 if (path == NULL) /* no environment variable? */
596 lua_pushstring(L, def); /* use default */
597 else {
598 /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */
599 path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP,
600 LUA_PATHSEP AUXMARK LUA_PATHSEP);
601 luaL_gsub(L, path, AUXMARK, def);
602 lua_remove(L, -2);
603 }
604 setprogdir(L);
605 lua_setfield(L, -2, fieldname);
606}
607
608
609static const luaL_Reg pk_funcs[] = {

Callers 1

luaopen_packageFunction · 0.85

Calls 5

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