diff options
| author | Oskari Timperi <oskari.timperi@iki.fi> | 2017-04-10 19:13:20 +0300 |
|---|---|---|
| committer | Oskari Timperi <oskari.timperi@iki.fi> | 2017-04-10 19:13:20 +0300 |
| commit | 00a42fe25c230ff257a50c6d2b9699004d426987 (patch) | |
| tree | 17e7eac0aa9c0522672fd8286d061d93e8560527 | |
| parent | 89025b0a5987ad9c995cd6e711e6b0822e094429 (diff) | |
| download | mkpdf-00a42fe25c230ff257a50c6d2b9699004d426987.tar.gz mkpdf-00a42fe25c230ff257a50c6d2b9699004d426987.zip | |
Make lua search lua files from under current directory on Linux/OSX
| -rw-r--r-- | src/main.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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)); |
