This diff adds official fixes from http://www.lua.org/bugs.html.
While here, use SUBST_CMD instead of the perl goo and adjust PKGNAME.

Comments? OK ?

cheers,
david

Index: Makefile
===================================================================
RCS file: /cvs/ports/lang/lua/Makefile,v
retrieving revision 1.36
diff -u -p -r1.36 Makefile
--- Makefile    24 Jun 2009 14:19:06 -0000      1.36
+++ Makefile    17 May 2010 06:37:45 -0000
@@ -3,7 +3,7 @@
 COMMENT=       powerful, light-weight programming language
 
 DISTNAME=      lua-5.1.4
-PKGNAME=       lua-5.1.4p0
+PKGNAME=       ${DISTNAME}p1
 CATEGORIES=    lang
 
 MASTER_SITES=  http://www.lua.org/ftp/ \
@@ -28,7 +28,7 @@ WANTLIB=      c m edit curses
 NO_REGRESS=    Yes
 
 pre-configure:
-       @perl -pi -e 's:\...@prefix@:${PREFIX}/:g;' ${WRKSRC}/etc/lua.pc
+       ${SUBST_CMD} ${WRKSRC}/etc/lua.pc
 
 post-install:
        ${INSTALL_DATA_DIR} ${PREFIX}/lib/pkgconfig
Index: patches/patch-etc_lua_pc
===================================================================
RCS file: /cvs/ports/lang/lua/patches/patch-etc_lua_pc,v
retrieving revision 1.5
diff -u -p -r1.5 patch-etc_lua_pc
--- patches/patch-etc_lua_pc    7 Nov 2008 12:23:12 -0000       1.5
+++ patches/patch-etc_lua_pc    17 May 2010 06:37:45 -0000
@@ -1,12 +1,12 @@
 $OpenBSD: patch-etc_lua_pc,v 1.5 2008/11/07 12:23:12 jsg Exp $
---- etc/lua.pc.orig    Fri Aug  8 22:46:11 2008
-+++ etc/lua.pc Thu Nov  6 21:43:38 2008
+--- etc/lua.pc.orig    Mon May 17 08:16:40 2010
++++ etc/lua.pc Mon May 17 08:16:43 2010
 @@ -8,7 +8,7 @@ V= 5.1
  R= 5.1.4
  
  # grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/'
 -prefix= /usr/local
-+prefix= @prefix@
++prefix= ${PREFIX}
  INSTALL_BIN= ${prefix}/bin
  INSTALL_INC= ${prefix}/include
  INSTALL_LIB= ${prefix}/lib
Index: patches/patch-src_lcode_c
===================================================================
RCS file: patches/patch-src_lcode_c
diff -N patches/patch-src_lcode_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_lcode_c   17 May 2010 06:37:45 -0000
@@ -0,0 +1,54 @@
+$OpenBSD$
+--- src/lcode.c.orig   Fri Dec 28 16:32:23 2007
++++ src/lcode.c        Mon May 17 08:19:26 2010
+@@ -1,5 +1,5 @@
+ /*
+-** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $
++** $Id: lcode.c,v 2.25.1.4 2009/06/15 14:12:25 roberto Exp $
+ ** Code generator for Lua
+ ** See Copyright Notice in lua.h
+ */
+@@ -544,15 +544,18 @@ void luaK_goiftrue (FuncState *fs, expdesc *e) {
+       pc = NO_JUMP;  /* always true; do nothing */
+       break;
+     }
+-    case VFALSE: {
+-      pc = luaK_jump(fs);  /* always jump */
+-      break;
+-    }
+     case VJMP: {
+       invertjump(fs, e);
+       pc = e->u.s.info;
+       break;
+     }
++    case VFALSE: {
++      if (!hasjumps(e)) {
++        pc = luaK_jump(fs);  /* always jump */
++        break;
++      }
++      /* else go through */
++    }
+     default: {
+       pc = jumponcond(fs, e, 0);
+       break;
+@@ -572,13 +575,16 @@ static void luaK_goiffalse (FuncState *fs, expdesc *e)
+       pc = NO_JUMP;  /* always false; do nothing */
+       break;
+     }
+-    case VTRUE: {
+-      pc = luaK_jump(fs);  /* always jump */
+-      break;
+-    }
+     case VJMP: {
+       pc = e->u.s.info;
+       break;
++    }
++    case VTRUE: {
++      if (!hasjumps(e)) {
++        pc = luaK_jump(fs);  /* always jump */
++        break;
++      }
++      /* else go through */
+     }
+     default: {
+       pc = jumponcond(fs, e, 1);
Index: patches/patch-src_ldblib_c
===================================================================
RCS file: patches/patch-src_ldblib_c
diff -N patches/patch-src_ldblib_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_ldblib_c  17 May 2010 06:37:45 -0000
@@ -0,0 +1,18 @@
+$OpenBSD$
+--- src/ldblib.c.orig  Mon Jan 21 14:11:21 2008
++++ src/ldblib.c       Mon May 17 08:19:26 2010
+@@ -1,5 +1,5 @@
+ /*
+-** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $
++** $Id: ldblib.c,v 1.104.1.4 2009/08/04 18:50:18 roberto Exp $
+ ** Interface from Lua to its debug API
+ ** See Copyright Notice in lua.h
+ */
+@@ -45,6 +45,7 @@ static int db_setmetatable (lua_State *L) {
+ 
+ 
+ static int db_getfenv (lua_State *L) {
++  luaL_checkany(L, 1);
+   lua_getfenv(L, 1);
+   return 1;
+ }
Index: patches/patch-src_liolib_c
===================================================================
RCS file: patches/patch-src_liolib_c
diff -N patches/patch-src_liolib_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_liolib_c  17 May 2010 06:37:45 -0000
@@ -0,0 +1,22 @@
+$OpenBSD$
+--- src/liolib.c.orig  Fri Jan 18 18:47:43 2008
++++ src/liolib.c       Mon May 17 08:19:26 2010
+@@ -1,5 +1,5 @@
+ /*
+-** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $
++** $Id: liolib.c,v 2.73.1.4 2010/05/14 15:33:51 roberto Exp $
+ ** Standard I/O (and system) library
+ ** See Copyright Notice in lua.h
+ */
+@@ -276,7 +276,10 @@ static int read_number (lua_State *L, FILE *f) {
+     lua_pushnumber(L, d);
+     return 1;
+   }
+-  else return 0;  /* read fails */
++  else {
++    lua_pushnil(L);  /* "result" to be removed */
++    return 0;  /* read fails */
++  }
+ }
+ 
+ 
Index: patches/patch-src_llex_c
===================================================================
RCS file: patches/patch-src_llex_c
diff -N patches/patch-src_llex_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_llex_c    17 May 2010 06:37:45 -0000
@@ -0,0 +1,22 @@
+$OpenBSD$
+--- src/llex.c.orig    Thu Dec 27 14:02:25 2007
++++ src/llex.c Mon May 17 08:19:26 2010
+@@ -1,5 +1,5 @@
+ /*
+-** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
++** $Id: llex.c,v 2.20.1.2 2009/11/23 14:58:22 roberto Exp $
+ ** Lexical Analyzer
+ ** See Copyright Notice in lua.h
+ */
+@@ -118,8 +118,10 @@ TString *luaX_newstring (LexState *ls, const char *str
+   lua_State *L = ls->L;
+   TString *ts = luaS_newlstr(L, str, l);
+   TValue *o = luaH_setstr(L, ls->fs->h, ts);  /* entry for `str' */
+-  if (ttisnil(o))
++  if (ttisnil(o)) {
+     setbvalue(o, 1);  /* make sure `str' will not be collected */
++    luaC_checkGC(L);
++  }
+   return ts;
+ }
+ 
Index: patches/patch-src_loadlib_c
===================================================================
RCS file: patches/patch-src_loadlib_c
diff -N patches/patch-src_loadlib_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_loadlib_c 17 May 2010 06:37:45 -0000
@@ -0,0 +1,19 @@
+$OpenBSD$
+--- src/loadlib.c.orig Wed Aug  6 15:29:28 2008
++++ src/loadlib.c      Mon May 17 08:19:26 2010
+@@ -1,5 +1,5 @@
+ /*
+-** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $
++** $Id: loadlib.c,v 1.52.1.4 2009/09/09 13:17:16 roberto Exp $
+ ** Dynamic library loader for Lua
+ ** See Copyright Notice in lua.h
+ **
+@@ -639,7 +639,7 @@ LUALIB_API int luaopen_package (lua_State *L) {
+   lua_pushvalue(L, -1);
+   lua_replace(L, LUA_ENVIRONINDEX);
+   /* create `loaders' table */
+-  lua_createtable(L, 0, sizeof(loaders)/sizeof(loaders[0]) - 1);
++  lua_createtable(L, sizeof(loaders)/sizeof(loaders[0]) - 1, 0);
+   /* fill it with pre-defined loaders */
+   for (i=0; loaders[i] != NULL; i++) {
+     lua_pushcfunction(L, loaders[i]);
Index: patches/patch-src_lstrlib_c
===================================================================
RCS file: /cvs/ports/lang/lua/patches/patch-src_lstrlib_c,v
retrieving revision 1.3
diff -u -p -r1.3 patch-src_lstrlib_c
--- patches/patch-src_lstrlib_c 7 Nov 2008 12:23:12 -0000       1.3
+++ patches/patch-src_lstrlib_c 17 May 2010 06:37:45 -0000
@@ -1,7 +1,7 @@
 $OpenBSD: patch-src_lstrlib_c,v 1.3 2008/11/07 12:23:12 jsg Exp $
---- src/lstrlib.c.orig Sat Jul 12 03:27:21 2008
-+++ src/lstrlib.c      Thu Nov  6 21:43:39 2008
-@@ -746,10 +746,9 @@ static const char *scanformat (lua_State *L, const cha
+--- src/lstrlib.c.orig Fri Jul 11 19:27:21 2008
++++ src/lstrlib.c      Mon May 17 08:23:35 2010
+@@ -746,14 +746,14 @@ static const char *scanformat (lua_State *L, const cha
  
  static void addintlen (char *form) {
    size_t l = strlen(form);
@@ -15,7 +15,18 @@ $OpenBSD: patch-src_lstrlib_c,v 1.3 2008
  }
  
  
-@@ -772,22 +771,24 @@ static int str_format (lua_State *L) {
+ static int str_format (lua_State *L) {
++  int top = lua_gettop(L);
+   int arg = 1;
+   size_t sfl;
+   const char *strfrmt = luaL_checklstring(L, arg, &sfl);
+@@ -768,26 +768,29 @@ static int str_format (lua_State *L) {
+     else { /* format item */
+       char form[MAX_FORMAT];  /* to store the format (`%...') */
+       char buff[MAX_ITEM];  /* to store the formatted item */
+-      arg++;
++      if (++arg > top)
++      luaL_argerror(L, arg, "no value");
        strfrmt = scanformat(L, strfrmt, form);
        switch (*strfrmt++) {
          case 'c': {
@@ -44,7 +55,7 @@ $OpenBSD: patch-src_lstrlib_c,v 1.3 2008
            break;
          }
          case 'q': {
-@@ -805,7 +806,7 @@ static int str_format (lua_State *L) {
+@@ -805,7 +808,7 @@ static int str_format (lua_State *L) {
              continue;  /* skip the `addsize' at the end */
            }
            else {
Index: patches/patch-src_lvm_c
===================================================================
RCS file: patches/patch-src_lvm_c
diff -N patches/patch-src_lvm_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_lvm_c     17 May 2010 06:37:45 -0000
@@ -0,0 +1,29 @@
+$OpenBSD$
+--- src/lvm.c.orig     Fri Dec 28 16:32:23 2007
++++ src/lvm.c  Mon May 17 08:19:26 2010
+@@ -1,5 +1,5 @@
+ /*
+-** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $
++** $Id: lvm.c,v 2.63.1.4 2009/07/01 21:10:33 roberto Exp $
+ ** Lua virtual machine
+ ** See Copyright Notice in lua.h
+ */
+@@ -133,6 +133,7 @@ void luaV_gettable (lua_State *L, const TValue *t, TVa
+ 
+ void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
+   int loop;
++  TValue temp;
+   for (loop = 0; loop < MAXTAGLOOP; loop++) {
+     const TValue *tm;
+     if (ttistable(t)) {  /* `t' is a table? */
+@@ -152,7 +153,9 @@ void luaV_settable (lua_State *L, const TValue *t, TVa
+       callTM(L, tm, t, key, val);
+       return;
+     }
+-    t = tm;  /* else repeat with `tm' */ 
++    /* else repeat with `tm' */
++    setobj(L, &temp, tm);  /* avoid pointing inside table (may rehash) */
++    t = &temp;
+   }
+   luaG_runerror(L, "loop in settable");
+ }

Reply via email to