[imapfilter-devel] which lua version?

pw woelfel at gmx.net
Fri May 7 14:37:43 EEST 2004


Hi,
I have used imapfilter+lua-1.0-rc2 without problems. But since rc3 is 
available only without lua, I compiled lua-5.0.2 myself and got errors on 
using the function "pclose". imapfilter-1.0-rc3 worked with the lua-code from
imapfilter+lua-1.0-rc2, though. The reason seems to be the difference between 
the lua code distributed by imapfilter and the original lua-5.0.2 code, as 
can be seen by the output of diff below.
Strange, because from the files distributed by imapfilter, it seems that 
lua-5.0.2 is used there, too...

any comments?
-- pw


# diff -rc lua-5.0.2/src/lib/liolib.c 
imapfilter+lua-1.0-rc2/lua/src/lib/liolib.c
*** lua-5.0.2/src/lib/liolib.c	2003-10-01 15:16:49.000000000 +0200
--- imapfilter+lua-1.0-rc2/lua/src/lib/liolib.c	2004-05-06 00:27:53.000000000 
+0200
***************
*** 149,155 ****
    if (f == stdin || f == stdout || f == stderr)
      return 0;  /* file cannot be closed */
    else {
!     int ok = (pclose(f) != -1) || (fclose(f) == 0);
      if (ok)
        *(FILE **)lua_touserdata(L, 1) = NULL;  /* mark file as closed */
      return ok;
--- 149,155 ----
    if (f == stdin || f == stdout || f == stderr)
      return 0;  /* file cannot be closed */
    else {
!     int ok = (fclose(f) == 0);
      if (ok)
        *(FILE **)lua_touserdata(L, 1) = NULL;  /* mark file as closed */
      return ok;
***************
*** 166,171 ****
--- 166,206 ----
  }
  
  
+ static int aux_pclose (lua_State *L) {
+   FILE *f = tofile(L, 1);
+   if (f == stdin || f == stdout || f == stderr)
+     return 0;  /* file cannot be closed */
+   else {
+     int ok = pclose(f);
+     if (ok != -1)
+       *(FILE **)lua_touserdata(L, 1) = NULL;  /* mark file as closed */
+     return ok;
+   }
+ }
+ 
+ 
+ static int io_pclose (lua_State *L) {
+ #if !USE_POPEN
+   luaL_error(L, "`pclose' not supported");
+   return 0;
+ #else
+   int i;
+   if (lua_isnone(L, 1) && lua_type(L, lua_upvalueindex(1)) == LUA_TTABLE) {
+     lua_pushstring(L, IO_OUTPUT);
+     lua_rawget(L, lua_upvalueindex(1));
+   }
+   i = aux_pclose(L) >> 8;
+   if (i == -1)
+     return pushresult(L, 0, NULL);
+   else {
+     pushresult(L, 1, NULL);
+     lua_pushnumber(L, (lua_Number)(i));
+     return 2;
+   }
+ #endif
+ }
+ 
+ 
  static int io_gc (lua_State *L) {
    FILE **f = topfile(L, 1);
    if (*f != NULL)  /* ignore closed files */
***************
*** 496,501 ****
--- 531,537 ----
    {"close", io_close},
    {"flush", io_flush},
    {"open", io_open},
+   {"pclose", io_pclose},
    {"popen", io_popen},
    {"read", io_read},
    {"tmpfile", io_tmpfile},
***************
*** 512,517 ****
--- 548,554 ----
    {"seek", f_seek},
    {"write", f_write},
    {"close", io_close},
+   {"pclose", io_pclose},
    {"__gc", io_gc},
    {"__tostring", io_tostring},
    {NULL, NULL}




More information about the Imapfilter-devel mailing list