Replace the standard Lua include path entirely on Windows

The default Lua include path is encoded with the local charset rather
than UTF-8. This causes problems when the working directory includes
non-latin-1 characters which are valid in the local charset, as Aegisub
expects the string to be UTF-8. As the default path isn't very useful on
Windows (on other platforms it could potentially include things like
luarocks-installed modules), just clear it.

Closes #1676.
This commit is contained in:
Thomas Goyne 2013-12-27 14:52:01 -08:00
parent 0a5a26a74d
commit 21b9fe1405

View file

@ -382,11 +382,15 @@ namespace Automation4 {
push_value(L, &pairs<table_ipairs>); push_value(L, &pairs<table_ipairs>);
lua_setglobal(L, "ipairs"); lua_setglobal(L, "ipairs");
// add include_path to the module load path // set the module load path to include_path
lua_getglobal(L, "package"); lua_getglobal(L, "package");
push_value(L, "path"); push_value(L, "path");
#ifdef __WXMSW__
push_value(L, "");
#else
push_value(L, "path"); push_value(L, "path");
lua_gettable(L, -3); lua_gettable(L, -3);
#endif
for (auto const& path : include_path) { for (auto const& path : include_path) {
lua_pushfstring(L, ";%s/?.lua;%s/?/init.lua", path.string().c_str(), path.string().c_str()); lua_pushfstring(L, ";%s/?.lua;%s/?/init.lua", path.string().c_str(), path.string().c_str());