Add new upstream Lua patches and rename all patches for consistency
authorFrancois Perrad <francois.perrad@gadz.org>
Thu, 5 Aug 2010 20:58:10 +0000 (22:58 +0200)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tue, 24 Aug 2010 13:04:57 +0000 (15:04 +0200)
Several new upstream patches against the latest version of Lua have
appeared on http://www.lua.org/bugs.html. This commit adds them to
Buildroot, and also renames the other patches to have a coherent patch
naming: lua-bugX, where X is the identifier of the bug as visible on
http://www.lua.org/bugs.html. Note that bug 1 and 2 are not associated
with patches, which explains why the first patch is labeled lua-bug3.

Fixes bug #2365.

Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
package/lua/lua-boolean_expression.patch [deleted file]
package/lua/lua-bug3-boolean_expression.patch [new file with mode: 0644]
package/lua/lua-bug4-table.patch [new file with mode: 0644]
package/lua/lua-bug5-debug_getfenv.patch [new file with mode: 0644]
package/lua/lua-bug6-gc_performance.patch [new file with mode: 0644]
package/lua/lua-bug7-string_format.patch [new file with mode: 0644]
package/lua/lua-bug8-io_read.patch [new file with mode: 0644]
package/lua/lua-debug_getfenv.patch [deleted file]
package/lua/lua-gc_performance.patch [deleted file]
package/lua/lua-table.patch [deleted file]

diff --git a/package/lua/lua-boolean_expression.patch b/package/lua/lua-boolean_expression.patch
deleted file mode 100644 (file)
index f04eb85..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
---- lua-5.1.4.orig/src/lcode.c 2007/12/28 15:32:23     2.25.1.3
-+++ lua-5.1.4/src/lcode.c      2009/06/15 14:07:34
-@@ -544,15 +544,18 @@
-       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,14 +575,17 @@
-       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);
-       break;
-
diff --git a/package/lua/lua-bug3-boolean_expression.patch b/package/lua/lua-bug3-boolean_expression.patch
new file mode 100644 (file)
index 0000000..f04eb85
--- /dev/null
@@ -0,0 +1,48 @@
+--- lua-5.1.4.orig/src/lcode.c 2007/12/28 15:32:23     2.25.1.3
++++ lua-5.1.4/src/lcode.c      2009/06/15 14:07:34
+@@ -544,15 +544,18 @@
+       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,14 +575,17 @@
+       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);
+       break;
+
diff --git a/package/lua/lua-bug4-table.patch b/package/lua/lua-bug4-table.patch
new file mode 100644 (file)
index 0000000..9ffc1bb
--- /dev/null
@@ -0,0 +1,22 @@
+--- lua-5.1.4.orig/src/lvm.c   2007/12/28 15:32:23     2.63.1.3
++++ lua-5.1.4/src/lvm.c        2009/07/01 20:36:59
+@@ -133,6 +133,7 @@
+ 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 @@
+       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");
+ }
+
diff --git a/package/lua/lua-bug5-debug_getfenv.patch b/package/lua/lua-bug5-debug_getfenv.patch
new file mode 100644 (file)
index 0000000..fce4d47
--- /dev/null
@@ -0,0 +1,10 @@
+--- lua-5.1.4.orig/src/ldblib.c        2007/12/28 15:32:23     2.63.1.3
++++ lua-5.1.4/src/ldblib.c     2010/02/23 12:36:59
+@@ -45,6 +45,7 @@
+ static int db_getfenv (lua_State *L) {
++  luaL_checkany(L, 1);
+   lua_getfenv(L, 1);
+   return 1;
+ }
diff --git a/package/lua/lua-bug6-gc_performance.patch b/package/lua/lua-bug6-gc_performance.patch
new file mode 100644 (file)
index 0000000..3c78525
--- /dev/null
@@ -0,0 +1,14 @@
+--- lua-5.1.4.orig/src/llex.c  2007/12/28 15:32:23     2.63.1.3
++++ lua-5.1.4/src/llex.c       2010/02/23 12:36:59
+@@ -118,8 +118,10 @@
+   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;
+ }
diff --git a/package/lua/lua-bug7-string_format.patch b/package/lua/lua-bug7-string_format.patch
new file mode 100644 (file)
index 0000000..68f3197
--- /dev/null
@@ -0,0 +1,20 @@
+--- lua-5.1.4.orig/src/lstrlib.c       2008/07/11 17:27:21     1.132.1.4
++++ lua-5.1.4/src/lstrlib.c    2010/05/14 15:12:53
+@@ -754,6 +754,7 @@
+ 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,7 +769,8 @@
+     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': {
diff --git a/package/lua/lua-bug8-io_read.patch b/package/lua/lua-bug8-io_read.patch
new file mode 100644 (file)
index 0000000..fb56bcf
--- /dev/null
@@ -0,0 +1,14 @@
+--- lua-5.1.4.orig/src/liolib.c        2008/01/18 17:47:43     2.73.1.3
++++ lua-5.1.4.orig/src/liolib.c        2010/05/14 15:29:29
+@@ -276,7 +276,10 @@
+     lua_pushnumber(L, d);
+     return 1;
+   }
+-  else return 0;  /* read fails */
++  else {
++    lua_pushnil(L);  /* "result" to be removed */
++    return 0;  /* read fails */
++  }
+ }
diff --git a/package/lua/lua-debug_getfenv.patch b/package/lua/lua-debug_getfenv.patch
deleted file mode 100644 (file)
index fce4d47..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
---- lua-5.1.4.orig/src/ldblib.c        2007/12/28 15:32:23     2.63.1.3
-+++ lua-5.1.4/src/ldblib.c     2010/02/23 12:36:59
-@@ -45,6 +45,7 @@
- static int db_getfenv (lua_State *L) {
-+  luaL_checkany(L, 1);
-   lua_getfenv(L, 1);
-   return 1;
- }
diff --git a/package/lua/lua-gc_performance.patch b/package/lua/lua-gc_performance.patch
deleted file mode 100644 (file)
index 3c78525..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
---- lua-5.1.4.orig/src/llex.c  2007/12/28 15:32:23     2.63.1.3
-+++ lua-5.1.4/src/llex.c       2010/02/23 12:36:59
-@@ -118,8 +118,10 @@
-   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;
- }
diff --git a/package/lua/lua-table.patch b/package/lua/lua-table.patch
deleted file mode 100644 (file)
index 9ffc1bb..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
---- lua-5.1.4.orig/src/lvm.c   2007/12/28 15:32:23     2.63.1.3
-+++ lua-5.1.4/src/lvm.c        2009/07/01 20:36:59
-@@ -133,6 +133,7 @@
- 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 @@
-       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");
- }
-