diff options
Diffstat (limited to 'src/mime.c')
-rw-r--r-- | src/mime.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -76,7 +76,17 @@ static UC b64unbase[256]; | |||
76 | \*-------------------------------------------------------------------------*/ | 76 | \*-------------------------------------------------------------------------*/ |
77 | MIME_API int luaopen_mime(lua_State *L) | 77 | MIME_API int luaopen_mime(lua_State *L) |
78 | { | 78 | { |
79 | lua_newtable(L); | 79 | /* whoever is loading the library replaced the global environment |
80 | * with the namespace table */ | ||
81 | lua_pushvalue(L, LUA_GLOBALSINDEX); | ||
82 | /* make sure library is still "requirable" if initialized staticaly */ | ||
83 | lua_pushstring(L, "_LOADEDLIB"); | ||
84 | lua_gettable(L, -2); | ||
85 | lua_pushstring(L, MIME_LIBNAME); | ||
86 | lua_pushcfunction(L, (lua_CFunction) luaopen_mime); | ||
87 | lua_settable(L, -3); | ||
88 | lua_pop(L, 1); | ||
89 | /* export functions */ | ||
80 | luaL_openlib(L, NULL, func, 0); | 90 | luaL_openlib(L, NULL, func, 0); |
81 | /* initialize lookup tables */ | 91 | /* initialize lookup tables */ |
82 | qpsetup(qpclass, qpunbase); | 92 | qpsetup(qpclass, qpunbase); |