| 605 | #define AUXMARK "\1" |
| 606 | |
| 607 | static void setpath (lua_State *L, const char *fieldname, const char *envname, |
| 608 | const char *def) { |
| 609 | const char *path = getenv(envname); |
| 610 | if (path == NULL) /* no environment variable? */ |
| 611 | lua_pushstring(L, def); /* use default */ |
| 612 | else { |
| 613 | /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ |
| 614 | path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP, |
| 615 | LUA_PATHSEP AUXMARK LUA_PATHSEP); |
| 616 | luaL_gsub(L, path, AUXMARK, def); |
| 617 | lua_remove(L, -2); |
| 618 | } |
| 619 | setprogdir(L); |
| 620 | lua_setfield(L, -2, fieldname); |
| 621 | } |
| 622 | |
| 623 | |
| 624 | static const luaL_Reg pk_funcs[] = { |
no test coverage detected