summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index bd303e6..0284f4d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -27,6 +27,11 @@ int main(int argc, char **argv)
struct optparse optparse;
const char *script;
+#if !defined(_WIN32)
+ size_t l;
+ const char *s;
+#endif
+
const struct optparse_long options[] =
{
{ "version", 'v', OPTPARSE_NONE },
@@ -72,6 +77,17 @@ int main(int argc, char **argv)
lua_setfield(L, -2, "hpdf");
lua_pop(L, 2);
+#if !defined(_WIN32)
+ // Setup package.path so that stuff is also searched from under the current
+ // directory (as in Windows).
+ lua_getglobal(L, "package");
+ lua_getfield(L, -1, "path");
+ s = lua_tolstring(L, -1, &l);
+ lua_pushfstring(L, "%s;./lua/?.lua;./lua/?/init.lua", s);
+ lua_setfield(L, -3, "path");
+ lua_pop(L, 2);
+#endif
+
if (luaL_dostring(L, mkpdf_lua))
{
fprintf(stderr, "%s\n", lua_tostring(L, -1));