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