aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lfs.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/lfs.c b/src/lfs.c
index 8234711..6259b6a 100644
--- a/src/lfs.c
+++ b/src/lfs.c
@@ -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[] = {
881int luaopen_lfs (lua_State *L) { 878int 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}