| 590 | #define AUXMARK "\1" |
| 591 | |
| 592 | static 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 | |
| 609 | static const luaL_Reg pk_funcs[] = { |
no test coverage detected