lua-users home
lua-l archive

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


Hi Leo/Luiz.

May I ask for the inclusion of glob() to lposix:

static int Pglob(lua_State *L)			/** glob(pattern) */
{
  const char *pattern = luaL_optstring(L, 1, "*");
  glob_t globres;
  
  if (glob(pattern, 0, NULL, &globres))
    return pusherror(L, pattern);
  else
    {
      int i;
      lua_newtable(L);
      for (i=1; i<=globres.gl_pathc; i++) {
        lua_pushstring(L, globres.gl_pathv[i-1]);
        lua_rawseti(L, -2, i);
      }
      globfree(&globres);
      return 1;
    }
}

Cheers,
George


On Thu, 2006-10-12 at 19:29, Leo Razoumov wrote:
> On 10/10/06, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
> >
> > The version posted in April is still valid. I did not get much feedback on
> > it and I still have to find the time to work on it right now.
> >
> > > I am very much interested in having "native" Lua 5.1 version that
> > > supports new module system. Any suggestions?
> >
> > The April verison should work perfectly with Lua 5.1. Did you have any problems?
> 
> Hi Luiz,
> I tried 2006-04-07 version of lposix.c found in your email
> http://lua-users.org/lists/lua-l/2006-04/msg00162.html
> 
> It compiles OK. However, several functions (found in previous version)
> are missing and some functions are broken. Also, due to lposix API
> changes test.lua does not run anymore with the April version of
> lposix.c.
> 
> Specifically, in April 2006 version of lposix.c I found the following problems:
>   * modemunch(...) function  does not parse mode string correctly.
>     As a result Pumask and Pchmod don't work.
>   * Functions Prmdir, Punlink are missing
>   * Function Ptimes: invalid conversion of clock ticks to seconds.
>     Macro CLOCKS_PER_SEC  is a wrong way to convert clock ticks to seconds.
>   * test.lua is broken due to lposix.c API changes.
> 
> GOOD NEWS: I took my time and fixed the problems I saw. Below I
> attached a tar-ball with the modified version of lposix module. I
> tested it on Linux (kernel 2.6.13, libc-2.3.5, GCC-4.0.2) with
> Lua-5.1.1 as a loadable module as well as statically linked  into lua
> interpreter. Everything seems to work  and test.lua output makes sense
> (on a first glance:-)  I cherry-picked some code from lposix.c 5.0
> version.
> 
> Still Outstanding issues: Function Pumask(...) does not take mask in
> octal form. Only alphabetic form like "a=rwx" works. I hope to find
> some time this weekend to fix it.
> 
> Please, feel free to merge my modifications into the next version of
> lposix module.
> 
> Best Regards,
> --Leo--
> 
> --Detailed ChangeLog follows:--
> 
> 2006-10-12  Leo Razoumov <slonik.az@gmail.com>
>   * Starting with Luiz Henrique de Figueiredo (LHF) 2006-04-07 version of
>     lposix.c fixed the following problems when compiling for Lua-5.1 (Lua-5.1.x)
>     o Added missing functions to lposix.c: Prmdir, Punlink
>     o Restored older lposix-5.0 implementation of the following functions:
>       Pumask, Pchmod
>   * restored modemuncher.c from lposix-5.0 since April 2006 lposix.c
> version has broken
>     implementation of modemunch(...) function.
>   * Functions Ptimes: wrong conversion of clock ticks to seconds. Replaced
>     scaling by CLOCKS_PER_SEC macro (that should never be used, btw) with
>     POSIX compliant sysconf(_SC_CLK_TCK) value.
>   * Update test.lua and tree.lua to reflect lposix.c API changes
>   * Deleted posix.lua loader file not needed anymore in Lua-5.1 module system
>   * Remaining problems: Pumask does not take mask in octal form, it only
>     understand alphabetic notation like "u=rwx"