lua-users home
lua-l archive

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


Well, after dorking around, I made a couple of changes to get lhf's
posix library to work with lua under cygwin, using lua 5.0.2.

Working with the lposix out of the box just didn't gibe for me; I
eventually got a lposix library built, but whenever I tried to use the
functionality via loadlib, it failed miserably for me which led to my
current implementation.

I hacked the source of the code to essentially add the capability to
the lua interpreter, so this approach is by no means ideal. However, if
your interest is to have something small and lightweight that can do
directory traversal and file manipulation without having to tote around a
large perl/python distro, then this might work for you...

My diff of the original lua.c & my new lua.c
----------------------%<------------------------
19c19
<
---
#include "lposix.h"
78a79
  {"posix", luaopen_posix},
----------------------%<------------------------

My diff of the original lua/Makefile & my new lua/Makefile
----------------------%<------------------------
8,9c8,9
< OBJS= lua.o
< SRCS= lua.c
---
OBJS= lua.o lposix.o
SRCS= lua.c lposix.c
----------------------%<------------------------

I then copied lposix.c and modemuncher.c into the src/lua directory.

My diff of the original lposix.c & new lposix.c
----------------------%<------------------------
28a29
#define _SC_STREAM_MAX 100 /*KAP*/
30a32
#include "lposix.h" /*KAP*/

I created a new file lposix.h co-located with lposix.c et al in the
src/lua directory, with the following in it
----------------------%<------------------------
#ifndef _lposix_h_
#define _lpoxis_h_

#define LUA_POSIX "posix"
LUALIB_API int luaopen_posix (lua_State *L);
#endif
----------------------%<------------------------

Just follow the standard installation instructions at this point (e.g.,
make & make install at the lua root directory).

running lua on the test.lua file shipped with lposix results in successful
tests.

I don't know if this is of interest to anyone, but here it is...enjoy!

Keith
--
Keith Pimmel     ~~~~     Dynetics, Inc.     ~~~~     256.964.4717