lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Aug 04, 2011 at 11:41:33AM +0200, HyperHacker wrote:
> On Thu, Aug 4, 2011 at 00:21, steve donovan <steve.j.donovan@gmail.com> wrote:
> > On Wed, Aug 3, 2011 at 10:48 PM, Luiz Henrique de Figueiredo
> > <lhf@tecgraf.puc-rio.br> wrote:
> >> #define luaL_reg luaL_Reg
> >
> > In fact, no rebuilding necessary - just put that #define in lfs.c and
> > then either
> > (a) accept that there is no longer a global 'lfs' table
> > (b) write a little bit of C that makes the global 'lfs' table for compatibility
> >
> > (a) is easy to live with, I think; most of us tend to do this anyway:
> >
> > local lfs = require 'lfs'
> >
> > steve d.
> >
> >
> 
> Using a local like that is good practice, but in this case, you could
> even just drop the "local" keyword and there you go, your old scripts
> that depended on the global work again. No C hacking necessary.
> 
In fact, in an interactive session, the 'local' loses the library 
straight off.

I needed a little more than Steve says, using Lua 5.2 as installed by
"sudo make install linux".

1. In lfs.h,
+ #define luaL_reg luaL_Reg

2. In lfs.c, 
-   luaL_register (L, "lfs", fslib);
+   luaL_newlib (L, fslib);

3. In config,
- LUA_LIBDIR= $(PREFIX)/lib/lua/5.1
+ LUA_LIBDIR= $(PREFIX)/lib/lua/5.2
- LUA_LIB= -llua -lauxlib
+ LUA_LIB= -L$(PREFIX)/lib -llua

With these changes, I now have lfs for Lua 5.2.  Thanks, everybody!

Dirk