MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / setpath

Function setpath

lua/loadlib.c:597–611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

595#define AUXMARK "\1"
596
597static void setpath (lua_State *L, const char *fieldname, const char *envname,
598 const char *def) {
599 const char *path = getenv(envname);
600 if (path == NULL) /* no environment variable? */
601 lua_pushstring(L, def); /* use default */
602 else {
603 /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */
604 path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP,
605 LUA_PATHSEP AUXMARK LUA_PATHSEP);
606 luaL_gsub(L, path, AUXMARK, def);
607 lua_remove(L, -2);
608 }
609 setprogdir(L);
610 lua_setfield(L, -2, fieldname);
611}
612
613
614static 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