diff options
author | Fabio Mascarenhas <mascarenhas@gmail.com> | 2012-10-04 07:00:22 -0700 |
---|---|---|
committer | Fabio Mascarenhas <mascarenhas@gmail.com> | 2012-10-04 07:00:22 -0700 |
commit | 62d5dbe3b6375e19573ad8f8af23df318bb05042 (patch) | |
tree | 899cba2237f04413e54165b0f513ed6ba0735a6b /src | |
parent | 944e325e2930a19ed7783816def8cd94508a15f8 (diff) | |
parent | f42c1a1a38cb6ee448bbb36fb5c8fadeebef84fc (diff) | |
download | luafilesystem-62d5dbe3b6375e19573ad8f8af23df318bb05042.tar.gz luafilesystem-62d5dbe3b6375e19573ad8f8af23df318bb05042.tar.bz2 luafilesystem-62d5dbe3b6375e19573ad8f8af23df318bb05042.zip |
Merge pull request #18 from devurandom/fix/lua52
Full Lua 5.2 compatibility and adherance to modules-create-no-globals
Diffstat (limited to 'src')
-rw-r--r-- | src/lfs.c | 25 |
1 files changed, 12 insertions, 13 deletions
@@ -56,20 +56,17 @@ | |||
56 | #include <utime.h> | 56 | #include <utime.h> |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | #define LUA_COMPAT_ALL | 59 | #include <lua.h> |
60 | #include "lua.h" | 60 | #include <lauxlib.h> |
61 | #include "lauxlib.h" | 61 | #include <lualib.h> |
62 | #include "lualib.h" | 62 | |
63 | #include "lfs.h" | 63 | #include "lfs.h" |
64 | 64 | ||
65 | /* | 65 | #define LFS_VERSION "1.6.2" |
66 | * ** compatibility with Lua 5.2 | 66 | #define LFS_LIBNAME "lfs" |
67 | * */ | ||
68 | #if (LUA_VERSION_NUM == 502) | ||
69 | #undef luaL_register | ||
70 | #define luaL_register(L,n,f) \ | ||
71 | { if ((n) == NULL) luaL_setfuncs(L,f,0); else luaL_newlib(L,f); } | ||
72 | 67 | ||
68 | #if LUA_VERSION_NUM < 502 | ||
69 | # define luaL_newlib(L,l) (lua_newtable(L), luaL_register(L,NULL,l)) | ||
73 | #endif | 70 | #endif |
74 | 71 | ||
75 | /* Define 'strerror' for systems that do not implement it */ | 72 | /* Define 'strerror' for systems that do not implement it */ |
@@ -856,7 +853,7 @@ static void set_info (lua_State *L) { | |||
856 | lua_pushliteral (L, "LuaFileSystem is a Lua library developed to complement the set of functions related to file systems offered by the standard Lua distribution"); | 853 | lua_pushliteral (L, "LuaFileSystem is a Lua library developed to complement the set of functions related to file systems offered by the standard Lua distribution"); |
857 | lua_settable (L, -3); | 854 | lua_settable (L, -3); |
858 | lua_pushliteral (L, "_VERSION"); | 855 | lua_pushliteral (L, "_VERSION"); |
859 | lua_pushliteral (L, "LuaFileSystem 1.6.0"); | 856 | lua_pushliteral (L, "LuaFileSystem "LFS_VERSION); |
860 | lua_settable (L, -3); | 857 | lua_settable (L, -3); |
861 | } | 858 | } |
862 | 859 | ||
@@ -881,7 +878,9 @@ static const struct luaL_Reg fslib[] = { | |||
881 | int luaopen_lfs (lua_State *L) { | 878 | int luaopen_lfs (lua_State *L) { |
882 | dir_create_meta (L); | 879 | dir_create_meta (L); |
883 | lock_create_meta (L); | 880 | lock_create_meta (L); |
884 | luaL_register (L, "lfs", fslib); | 881 | luaL_newlib (L, fslib); |
882 | lua_pushvalue(L, -1); | ||
883 | lua_setglobal(L, LFS_LIBNAME); | ||
885 | set_info (L); | 884 | set_info (L); |
886 | return 1; | 885 | return 1; |
887 | } | 886 | } |