~panda-roux/MoonGem

8a2fa5f0e499c0b4249a0ba7332cfc09f906ee72 — panda-roux 6 months ago 89adac7
passing a copy into dirname because that method unintuitively modifies its argument
1 files changed, 3 insertions(+), 1 deletions(-)

M src/script.c
M src/script.c => src/script.c +3 -1
@@ 190,9 190,11 @@ static void append_package_path(script_ctx_t* ctx) {
  lua_getglobal(L, "package");
  lua_getfield(L, -1, "path");
  if (strrchr(path, '.') != NULL) {
    char* dir = dirname((char*)path);
    char* path_copy = strdup(path);
    char* dir = dirname(path_copy);
    lua_pushfstring(L, ";./%s/?.lua", dir);
    lua_pushfstring(L, ";./%s/?", dir);
    free(dir);
  } else {
    lua_pushfstring(L, ";./%s/?.lua", path);
    lua_pushfstring(L, ";./%s/?", path);