aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Schridde <devurandom@gmx.net>2012-10-03 02:54:08 +0200
committerDennis Schridde <devurandom@gmx.net>2012-10-03 02:54:08 +0200
commit8e7217e74fbe5da0a9c1fee03d191b5a0266cedd (patch)
tree5d40a50a0ce1ee9e88052407e81bf38808c3391f
parent944e325e2930a19ed7783816def8cd94508a15f8 (diff)
downloadluafilesystem-8e7217e74fbe5da0a9c1fee03d191b5a0266cedd.tar.gz
luafilesystem-8e7217e74fbe5da0a9c1fee03d191b5a0266cedd.tar.bz2
luafilesystem-8e7217e74fbe5da0a9c1fee03d191b5a0266cedd.zip
Full Lua 5.2 compatibility and adherance to modules-create-no-globals
-rw-r--r--doc/us/examples.html2
-rw-r--r--src/lfs.c20
2 files changed, 8 insertions, 14 deletions
diff --git a/doc/us/examples.html b/doc/us/examples.html
index 65a6623..d6d32fc 100644
--- a/doc/us/examples.html
+++ b/doc/us/examples.html
@@ -65,7 +65,7 @@
65attributes for each file inside it.</p> 65attributes for each file inside it.</p>
66 66
67<pre class="example"> 67<pre class="example">
68require"lfs" 68local lfs = require"lfs"
69 69
70function attrdir (path) 70function attrdir (path)
71 for file in lfs.dir(path) do 71 for file in lfs.dir(path) do
diff --git a/src/lfs.c b/src/lfs.c
index 8234711..8aa7412 100644
--- a/src/lfs.c
+++ b/src/lfs.c
@@ -56,20 +56,14 @@
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"
63#include "lfs.h"
64 62
65/* 63#include "lfs.h"
66 * ** compatibility with Lua 5.2
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 64
65#if LUA_VERSION_NUM < 502
66# define luaL_newlib(L,l) (lua_newtable(L), luaL_register(L,NULL,l))
73#endif 67#endif
74 68
75/* Define 'strerror' for systems that do not implement it */ 69/* Define 'strerror' for systems that do not implement it */
@@ -881,7 +875,7 @@ static const struct luaL_Reg fslib[] = {
881int luaopen_lfs (lua_State *L) { 875int luaopen_lfs (lua_State *L) {
882 dir_create_meta (L); 876 dir_create_meta (L);
883 lock_create_meta (L); 877 lock_create_meta (L);
884 luaL_register (L, "lfs", fslib); 878 luaL_newlib (L, fslib);
885 set_info (L); 879 set_info (L);
886 return 1; 880 return 1;
887} 881}