mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 16:28:30 +00:00
Update redbean ProgramDirectory to update package.path
(#823)
This commit is contained in:
parent
1422e96b4e
commit
5c40800d69
1 changed files with 17 additions and 0 deletions
|
@ -1076,6 +1076,22 @@ static bool HasString(struct Strings *l, const char *s, size_t n) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void UpdateLuaPath(const char *s) {
|
||||||
|
#ifndef STATIC
|
||||||
|
lua_State *L = GL;
|
||||||
|
int n = lua_gettop(L);
|
||||||
|
lua_getglobal(L, "package");
|
||||||
|
if (lua_istable(L, -1)) {
|
||||||
|
lua_getfield(L, -1, "path");
|
||||||
|
lua_pushstring(L, _gc(xasprintf("%s;%s/.lua/?.lua;%s/.lua/?/init.lua",
|
||||||
|
luaL_optstring(L, -1, ""), s, s)));
|
||||||
|
lua_setfield(L, -3, "path");
|
||||||
|
}
|
||||||
|
lua_settop(L, n);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ProgramDirectory(const char *path) {
|
static void ProgramDirectory(const char *path) {
|
||||||
char *s;
|
char *s;
|
||||||
size_t n;
|
size_t n;
|
||||||
|
@ -1087,6 +1103,7 @@ static void ProgramDirectory(const char *path) {
|
||||||
n = strlen(s);
|
n = strlen(s);
|
||||||
INFOF("(cfg) program directory: %s", s);
|
INFOF("(cfg) program directory: %s", s);
|
||||||
AddString(&stagedirs, s, n);
|
AddString(&stagedirs, s, n);
|
||||||
|
UpdateLuaPath(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ProgramHeader(const char *s) {
|
static void ProgramHeader(const char *s) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue